Java
Learn types, collections, and how to organize bigger programs.
Beginner
Your first Java program
A basic Java program starts in a method named main and can print text to the console.
Variables and types
Declare a Java variable and see how its type determines which values it can accept.
Strings and text comparisons
A Java String stores text and offers methods to inspect or transform it.
Reading and validating console input
Program input arrives as text, and you decide how to interpret it.
Conditions and loops
Decide which blocks run and trace how a Java loop advances its counter.
Methods and return values
Define a method with typed parameters and return a result to its caller.
Arrays and ArrayList
Use a fixed-size array or a resizable list and access items by index.
Enums and fixed choices
An enum names the fixed choices that are valid for one value.
Intermediate
Classes and objects
Combine state and behavior in a Java class and follow a constructor call.
Constructors and encapsulation
A constructor gives a new object its starting state, and private fields let the class protect that state.
Interfaces and polymorphism
An interface describes behavior that several classes can provide in their own way.
Generics and type parameters
A generic type lets one class or method work with several types while preserving type checks.
Maps and sets
A map looks up a value by key, and a set records whether a value is present.
Exceptions and resource handling
An exception carries failure information from the operation that failed to code that can handle it.
Lambdas and stream pipelines
A stream pipeline expresses work on a sequence as a chain of small operations.
Records and value equality
A record is a compact way to define a data carrier with named components.
Class composition and inheritance
Composition gives an object a collaborator, while inheritance gives a class the behavior and type relationship of a parent class.
Paths and text files
A Path describes a file or folder location, and Files provides operations that use that location.
Advanced
Threads, shared state, and atomicity
Concurrent tasks may take turns in the middle of an operation, so shared changes need coordination.
Combining asynchronous results
A CompletableFuture represents a value that may become available later.
References, garbage collection, and leaks
Java can reclaim an object when it is no longer reachable from the running program.
Understanding JVM performance
Java performance can change as the JVM learns which code paths are used often.