Java · early preview
Learn the language. Keep going into the runtime.
Start with the JVM and your first program. Finish with memory, garbage collection, locks, atomics, executors, and virtual threads. The order matters: each phase uses the model built before it.
Start with how Java runs14 phases57 lessons235 exercises20 hours of reading
- I
- II
Phase II
Data and Memory
Trace a Java value from source literal to bits, arithmetic, conversion, and output.
- 2.1Variables, Types, Literals, KeywordsStore values in variables and choose a type that fits the data.22 min
- 2.2How Numbers Live in MemorySee how Java stores whole numbers and decimal approximations as bits.26 min
- 2.3Type Conversion, Promotion, CastingPredict when Java changes a numeric type and what information the conversion can lose.24 min
- III
- IV
- V
- VI
Phase VI
Objects
Define reference types, construct valid objects, and trace identity, calls, and copying.
- 6.1Classes, Objects, and `new`Define a class and create objects that each hold their own field values.20 min
- 6.2Constructors, Chaining, `this`Use constructors to give every new object a valid starting state.20 min
- 6.3Objects in Memory: Size, Copying, PassingTrace references to explain shared objects, method arguments, copying, and object size.22 min
- 6.4`static` and `final`Use static for class-level data and final to prevent specific kinds of change.21 min
- VII
Phase VII
The Four Pillars
Closing objects off, building on them, and letting them choose their own behaviour.
- 7.1Encapsulation, Inheritance, Packages, and `super`Protect an object's rules and move genuinely shared behaviour into a parent class.28 min
- 7.2Abstraction, Polymorphism, Abstract Classes, and InterfacesUse one parent type while each child object provides its own behaviour.30 min
- 7.3Wrapper Types, Autoboxing, and POJOsSee when Java converts between primitives and wrapper objects, and avoid equality and null errors.26 min
- 7.4Static Nested, Inner, Local, and Anonymous ClassesChoose a nested-class form from the data and enclosing object it needs to access.29 min
- VIII
- 8.1Java I/O: Streams, Scanner, BufferedReaderRead keyboard and file input with Scanner and BufferedReader, distinguish byte streams from character readers, and explain why buffering improves performance.19 min
- 8.2Immutable ClassesBuild an immutable class by controlling construction, reassignment, mutation, inheritance, and references to mutable data.17 min
- 8.3The Object Class: `equals`, `hashCode`, `toString`Override equals, hashCode, and toString correctly, and follow the equality contract required by hash-based collections.24 min
- 8.4EnumsDefine a fixed set of named values, attach fields and methods to them, and use exhaustive switch expressions safely.18 min
- 8.5Interface Methods and Functional InterfacesDistinguish abstract, default, static, private, marker, and functional interface features and choose each for a specific purpose.20 min
- IX
- 9.1Strings: The Pool and ImmutabilityExplain String immutability, literal pooling, object identity, and why text content must be compared with equals rather than ==.19 min
- 9.2String Methods and StringBuilderUse the String methods needed for search, slicing, cleanup, and comparison, then build changing text efficiently with StringBuilder.17 min
- 9.3GenericsDeclare generic classes and methods, apply type bounds, and explain how compile-time type checks replace unsafe Object casts.20 min
- 9.4Wildcards: `extends` and `super`Explain generic invariance and use unbounded, extends, and super wildcards without giving up type safety.18 min
- X
- 10.1The Collections FrameworkChoose List, Set, Queue, or Map from the operations, ordering, duplicate, and lookup behaviour your program requires.19 min
- 10.2Iterable and the IteratorImplement and use Iterable and Iterator, trace how for-each obtains elements, and remove elements without corrupting traversal.18 min
- 10.3The Collection InterfaceUse the core Collection operations, bulk methods, array conversion, and optional operations shared across collection types.16 min
- 10.4List: ArrayList, LinkedList, Vector, StackCompare ArrayList and LinkedList by operation cost, and recognise why the older Vector and Stack classes are usually replaced.19 min
- 10.5Set and Map: Inside HashMapUse Set and Map, trace a HashMap lookup through hashing and equality, and predict the effect of collisions and mutable keys.24 min
- 10.6Map Operations and Specialized MapsUse Map update and lookup methods, then choose among HashMap, LinkedHashMap, TreeMap, EnumMap, IdentityHashMap, and WeakHashMap.18 min
- 10.7Queue, Deque, and PriorityQueueUse Queue and Deque operations, distinguish FIFO from priority ordering, and trace how PriorityQueue stores a binary heap in an array.18 min
- 10.8Comparable, Comparator, and SortingDefine natural ordering with Comparable, supply alternative orderings with Comparator, and keep comparison consistent with equality where required.20 min
- XI
- 11.1Lambdas and Functional InterfacesReplace small anonymous-class implementations with lambda expressions and match each lambda to a functional interface method.20 min
- 11.2Method References and the Four ShapesUse Function, Predicate, Supplier, and Consumer, then replace eligible lambdas with the four forms of method reference.21 min
- 11.3Streams, and When the Work HappensBuild a stream pipeline, distinguish intermediate from terminal operations, and predict how laziness and short-circuiting control execution.20 min
- 11.4Stream Operations and CollectorsChoose transformation, filtering, ordering, reduction, matching, and collection operations from the result your pipeline must produce.21 min
- 11.5OptionalRepresent an absent result explicitly, transform present values safely, and avoid Optional patterns that recreate null checks or hide errors.19 min
- 11.6Parallel and Primitive StreamsUse IntStream, LongStream, and DoubleStream to avoid boxing, then decide when parallel execution is safe and likely to help.20 min
- XII
Phase XII
When Things Go Wrong
Diagnosing failures, reading stack traces, and designing exception handling.
- 12.1Exceptions, Errors, and the Stack TraceDistinguish normal returns from thrown failures, read a stack trace from the failure outward, and use try, catch, finally, and try-with-resources.20 min
- 12.2Checked, Unchecked, and Exceptions of Your OwnDistinguish checked exceptions, unchecked exceptions, and errors, then design custom exceptions that preserve useful causes and recovery choices.21 min
- XIII
Phase XIII
Memory and the Garbage Collector
JVM memory areas, reachability, collection, and memory leaks.
- 13.1JVM Memory AreasPlace call frames, objects, class metadata, run-time constants, native work, and per-thread execution state in the JVM memory model.20 min
- 13.2Reachability and Garbage CollectionDetermine object reachability from garbage-collection roots, explain why cycles can be collected, and identify references that cause memory leaks.21 min
- XIV
Phase XIV
Concurrency
Threads, shared state, synchronization, atomics, executors, and virtual threads.
- 14.1Processes and ThreadsDistinguish processes from threads, identify per-thread and shared state, and observe the background threads present in a Java program.19 min
- 14.2Creating Threads and Thread StatesCreate work with Runnable and Thread, start it correctly, and interpret all six Thread.State values.19 min
- 14.3Interruption and Cooperative CancellationRequest thread cancellation with interruption, handle InterruptedException without losing the request, and coordinate shutdown with join.19 min
- 14.4Race Conditions, Atomicity, and VisibilityReproduce lost updates, stale reads, and ordering surprises, then separate the atomicity and visibility guarantees each fix requires.22 min
- 14.5synchronized and Monitor LocksSelect the correct monitor, define a protected invariant, limit critical-section size, and prevent deadlock with consistent lock ordering.21 min
- 14.6wait, notify, and notifyAllCoordinate threads with a condition predicate, call wait while holding the monitor, and recheck the predicate after every wake-up.20 min
- 14.7Explicit Locks and ConditionsUse ReentrantLock, timed and interruptible acquisition, Condition queues, and ReadWriteLock only when their extra control is required.21 min
- 14.8Atomic Variables and Compare-and-SwapUse atomic variables for single-value updates, implement a compare-and-swap retry loop, and recognise when an invariant still requires a lock.20 min
- 14.9CAS Retry Loops and the ABA ProblemExplain failed compare-and-swap retries, measure repeated work under contention, and detect state that changed and later returned to the same value.19 min
- 14.10Executors, Thread Pools, and FuturesSubmit Runnable and Callable tasks, retrieve results and failures through Future, size a thread pool, and choose a bounded task queue.21 min
- 14.11CompletableFuture and Virtual ThreadsCompose asynchronous results without blocking, propagate failures through a pipeline, and use virtual threads for large numbers of blocking tasks.22 min