Skip to content

About

Hands-on Java learning and interview revision: core concepts, collections, streams, concurrency and modern language features, built with Java 21 and Maven Wrapper.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

Java Learning Lab · Up to Java 21

Explore a concept. Read the code. Predict the result. Run it yourself.

Java 21 Maven Wrapper Hands-on practice

A collection of focused Java programs for building language fundamentals, exploring modern features and revising for technical interviews. Browse examples across object-oriented programming, collections, streams, concurrency and Java features through Java 21.

Quick start · Topic explorer · Learning paths · Interview revision · Project structure

What you can explore

  • Core Java: variables, types, control flow, strings and exception handling.
  • Object-oriented design: inheritance, interfaces, composition, abstraction and polymorphism.
  • Data processing: collections, generics, comparators, streams and collectors.
  • Concurrency: threads, synchronization, blocking queues, CompletableFuture and virtual threads.
  • Modern Java: records, sealed classes, text blocks, pattern matching and sequenced collections.

The examples live in topic folders, so you can study one concept at a time or use the repository as a reference alongside your own projects.

Quick start

Prerequisites

  • JDK 21 or newer, with java and javac available on your PATH.
  • Git to clone the repository.
  • Network access for the Maven Wrapper and dependencies on the first build.
git clone https://github.com/devendraghag/java_lts_upto21.git
cd java_lts_upto21
java -version
javac -version

Build

Windows PowerShell

.\mvnw.cmd clean package

macOS / Linux

./mvnw clean package

The examples target Java 21. The Maven Wrapper downloads the pinned Maven distribution on its first run, so a system Maven installation is not required. Maven reads the project-local .mvn/settings.xml instead of machine-level Maven settings.

Run your first example

After building, run the entry-point example:

java -cp target/classes com.example.helloworldways.HelloWorldEntryPointDemo Devendra

Expected output:

Hello, Devendra!
Hello from an overloaded helper method.

Prefer an IDE? Open the repository as a Maven project, select JDK 21 or newer, then run an example class with a public static void main(String[] args) method. Use the package declaration inside each source file to identify its fully qualified class name.

Topic explorer

Area Jump into the examples
Fundamentals Variables · Data types · Operators · Control flow · Loops
Object-oriented Java Constructors · Inheritance · Interfaces · Abstract classes · Composition
Methods and behavior Overloading · Overriding · Dynamic dispatch · Call by value
Strings and errors Strings · StringBuilder · String methods · Exception handling
Collections and types Collection classes · Generics · Comparable · Comparator · Collection conversions
Functional Java Lambdas · Functional interfaces · Method references · Optional
Streams and collectors Stream creation · Intermediate operations · Terminal operations · Collectors · Primitive streams
Concurrency Multithreading · Synchronization · Blocking queues · CompletableFuture · Virtual threads
Modern language features Records · Sealed classes · Text blocks · Switch expressions · Local type inference
Pattern matching and collections Pattern matching for instanceof · Pattern matching for switch · Record patterns · Sequenced collections
Further practice Interview programs · Design patterns · HTTP Client · Serialization

Browse all source folders

Choose a learning path

Your goal Suggested route
Learn Java fundamentals Variables and types → control flow → methods → strings → exceptions
Strengthen object-oriented design Constructors → inheritance → interfaces → composition → method overriding
Get comfortable with data processing Collections → generics → comparators → lambdas → streams → collectors
Explore modern Java Local type inference → switch expressions → text blocks → records → sealed classes → pattern matching
Study concurrency Multithreading → synchronization → blocking queues → CompletableFuture → virtual threads

Interview revision

For each topic, practise explaining:

  1. The rule: what does the language or API guarantee?
  2. The prediction: what output do you expect before running the program?
  3. The edge case: what changes for null, empty input, duplicate values or concurrent execution, where relevant?
  4. The tradeoff: when would you use this approach in an application?
Try a 20-minute revision session
  • 5 minutes: read one example and predict its output.
  • 5 minutes: run it and explain the result aloud.
  • 5 minutes: change one input locally and check your prediction.
  • 5 minutes: write a short explanation of the concept without looking at the source.

Project structure

java_lts_upto21/
├── src/main/java/com/example/example/  # Topic-based Java source folders
├── .mvn/                              # Maven Wrapper and project settings
├── mvnw                               # macOS / Linux wrapper
├── mvnw.cmd                           # Windows wrapper
├── pom.xml                            # Java 21 Maven build
└── README.md                          # Learning guide and navigation

The source directory has an extra example segment; package declarations determine the class names used by the Java launcher. Run individual examples after compiling rather than assuming the JAR has a single application entry point.

Build troubleshooting

  • Release version 21 not supported: check java -version, javac -version and the JDK selected by your IDE or Maven.
  • Class not found: build from the repository root and use the package declaration plus class name with java -cp target/classes.
  • Wrapper permission denied on macOS / Linux: use sh mvnw clean package.
  • Download failure: check network or proxy access and the project-local Maven settings.

Scope

This repository is a collection of learning examples and interview practice. The build targets Java 21; individual folders illustrate selected features and concepts, rather than an exhaustive specification or migration guide for every Java release.

About

Hands-on Java learning and interview revision: core concepts, collections, streams, concurrency and modern language features, built with Java 21 and Maven Wrapper.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages