everything
contents
18 parts, 192 chapters, in the order they build on each other. if you already know some java, skip around. every chapter links back to what it needs.
- 01.01what java actually isthe language, the JDK, the JVM, and why they're three different things.
- 01.02getting a JDKwhich JDK to install (there are like ten), JAVA_HOME, and an editor.
- 01.03hello, worldfrom void main() to public static void main(String[] args), and why both exist.
- 01.04compile and runjavac → .class → java. what each step actually produces.
- 01.05jshella REPL for java. the fastest way to try anything on this site.
- 01.06debugging and stack tracesbreakpoints, stepping, and reading a stack trace without panicking.
- 02.01variables and primitiveseight primitive types, how many bits each one gets, and what that means.
- 02.02operatorsprecedence, short-circuiting, and the ++i vs i++ thing.
- 02.03casting and overflowwidening, narrowing, and why Integer.MAX_VALUE + 1 is negative.
- 02.04floating pointwhy 0.1 + 0.2 != 0.3, IEEE 754 bit by bit, and when to reach for BigDecimal.
- 02.05strings, the basicsstring literals, immutability, concatenation and text blocks.
- 02.06control flowif, loops, break, continue, and labeled breaks (yes, java has those).
- 02.07switchthe old fallthrough switch vs the new arrow switch expression.
- 02.08arraysfixed-size boxes in a row. 2d arrays are arrays of arrays (literally).
- 02.09methodsparameters, return values, overloading and varargs.
- 02.10the call stack and recursionevery call pushes a frame. watch them stack up and unwind.
- 02.11stack and heapwhere your variables live vs where your objects live. the most important picture in java.
- 02.12java is pass-by-valuealways. even for objects. here's the proof, step by step.
- 02.13varlocal type inference: what it infers, and where it isn't allowed.
- 02.14reading and printingSystem.out, printf formatting, Scanner and IO.println.
- 03.01classes and objectsa class is a blueprint, new stamps out an object. what's actually in memory.
- 03.02constructors and init orderthe exact order fields, initializers and constructors run in.
- 03.03access controlprivate, package-private, protected, public. who can see what.
- 03.04staticone copy per class vs one copy per object.
- 03.05packages and importsfully qualified names, the classpath, and import module.
- 03.06inheritanceextends, super, and how a subclass object is laid out in memory.
- 03.07polymorphism and dynamic dispatchoverloading picks at compile time, overriding picks at runtime. the vtable.
- 03.08abstract classes and interfacesdefault methods, the diamond problem, and when to use which.
- 03.09equals, hashCode, toStringthe contracts every object signs, and what breaks when you don't keep them.
- 03.10enumstype-safe constants that are secretly full classes.
- 03.11nested and inner classesstatic nested, inner, local, anonymous. and the hidden this$0.
- 03.12immutabilityfinal fields, defensive copies, and the aliasing bug that ruins your day.
- 03.13composition over inheritancethe fragile base class problem, animated.
- 04.01the string apiStringBuilder, formatting, compact strings and the methods worth knowing.
- 04.02wrappers and autoboxingint vs Integer, the integer cache, and why 127 == 127 but 128 != 128.
- 04.03math and random numbersMath, StrictMath, BigInteger, and RandomGenerator.
- 04.04exceptionsThrowable, Error, Exception. checked vs unchecked.
- 04.05try, catch, finallyhow an exception unwinds the stack, frame by frame.
- 04.06try-with-resourcesautomatic closing, in reverse order, with suppressed exceptions.
- 04.07designing with exceptionscustom exceptions, chaining, and translating across layers.
- 04.08optionala box that might be empty. idioms and anti-patterns.
- 04.09dates and timeInstant vs LocalDateTime vs ZonedDateTime, and daylight saving traps.
- 04.10regular expressionsPattern, Matcher, groups, and how backtracking can melt your cpu.
- 04.11loggingSystem.Logger, java.util.logging, SLF4J. levels and where logs go.
- 05.01why generics existlife before generics was ClassCastException at 3am.
- 05.02generic types and methodswriting your own Box<T>, and how inference figures out T.
- 05.03bounded type parameters<T extends Comparable<? super T>> decoded.
- 05.04wildcards and PECS? extends vs ? super. producer extends, consumer super.
- 05.05type erasurewhat the compiler deletes, what it adds (bridge methods), and why.
- 05.06arrays, varargs and other limitsno new T(), no generic arrays, heap pollution and @SafeVarargs.
- 05.07generics at runtimetype tokens and the bits of type info that do survive erasure.
- 06.01the big picturethe interface family tree, from Iterable down to SequencedMap.
- 06.02ArrayListan array that grows. how much, when, and what it costs.
- 06.03LinkedList and ArrayDequenodes and pointers vs a circular buffer. (spoiler: use the deque.)
- 06.04HashMapbuckets, hashes, collisions, resizing. put a key in and watch where it lands.
- 06.05LinkedHashMap and LRU cachesa hashmap with a linked list threaded through it.
- 06.06TreeMap and sorted mapsa red-black tree that stays balanced while you insert.
- 06.07setsHashSet (a HashMap in disguise), TreeSet, and EnumSet (a bit vector).
- 06.08PriorityQueuea binary heap in an array. sift up, sift down.
- 06.09immutable collectionsList.of, copyOf, and unmodifiable views that aren't actually immutable.
- 06.10iterators and fail-fastmodCount and the ConcurrentModificationException you got in a single thread.
- 06.11sorting and comparatorsComparable, Comparator.comparing().thenComparing(), and TimSort.
- 06.12choosing a collectiona decision tree and a big-O cheat sheet.
- 07.01lambdassyntax, target typing, and why captured variables must be effectively final.
- 07.02functional interfacesFunction, Supplier, Consumer, Predicate and the rest of the zoo.
- 07.03method referencesthe four kinds of ::, and what each one desugars to.
- 07.04how a stream pipeline runssource → intermediate → terminal. lazy, one element at a time.
- 07.05stream operationsmap, filter, flatMap, sorted, distinct, limit, takeWhile.
- 07.06collectorstoList, groupingBy, partitioningBy, toMap, teeing.
- 07.07reductionreduce with identity, accumulator, combiner. and when to use collect instead.
- 07.08primitive streamsIntStream and friends, and the cost of boxing.
- 07.09gathererscustom intermediate operations: windows, scans, and mapConcurrent.
- 07.10parallel streamsspliterators, the common pool, and when parallel is slower.
- 08.01java 8 → 27every release, what it shipped, and the six-month train.
- 08.02preview and incubator features--enable-preview, and how features graduate.
- 08.03recordsdata carriers in one line. what the compiler generates for you.
- 08.04sealed typesclosed hierarchies the compiler can check exhaustively.
- 08.05pattern matchinginstanceof patterns, switch patterns, guards and dominance.
- 08.06record patternsdestructure records, nested, right in the pattern. plus _.
- 08.07data-oriented programmingrecords + sealed + patterns = algebraic data types in java.
- 08.08simpler programscompact source files, instance main, and import module.
- 08.09flexible constructor bodiesstatements before super(), finally.
- 08.10what's in preview right nowprimitive patterns, lazy constants, structured concurrency in jdk 27.
- 09.01threadsstarting threads, their lifecycle, and the six states.
- 09.02race conditionstwo threads, one counter++, and a lost update. interleave them yourself.
- 09.03synchronized and monitorsevery object has a lock. entry sets, reentrancy, and what it guards.
- 09.04wait and notifyguarded blocks, spurious wakeups, and why you should use something else.
- 09.05the java memory modelhappens-before, volatile, reordering, and safe publication.
- 09.06atomics and CAScompare-and-swap loops, AtomicInteger, LongAdder, and ABA.
- 09.07locks and AQSReentrantLock, ReadWriteLock, StampedLock, and the queue under all of them.
- 09.08executors and thread poolscore size, max size, the queue, and rejection. play with a pool.
- 09.09CompletableFutureasync pipelines: thenApply, thenCompose, allOf, and error handling.
- 09.10fork/join and work stealingsplit work recursively, idle threads steal from busy ones.
- 09.11concurrent collectionsConcurrentHashMap, CopyOnWriteArrayList, BlockingQueue.
- 09.12synchronizersCountDownLatch, CyclicBarrier, Semaphore, Phaser.
- 09.13deadlocks and livenessdeadlock, livelock, starvation. the dining philosophers, live.
- 09.14virtual threadsmillions of threads, mounted on a few carriers.
- 09.15structured concurrency and scoped valuestask trees that cancel together, and ThreadLocal's replacement.
- 09.16testing concurrent codewhy your test passed 1000 times and failed in prod. jcstress.
- 10.01i/o streamsInputStream, Reader, and the decorator onion.
- 10.02charsets and encodingchars are not bytes. UTF-8, UTF-16, and mojibake.
- 10.03files and pathsPath, Files, walking trees, and watching directories.
- 10.04buffers and channelsByteBuffer position, limit, flip. and memory-mapped files.
- 10.05serializationhow objects become bytes, and why everyone says don't.
- 10.06sockets and selectorsTCP, UDP, and one thread watching many connections.
- 10.07the http clientHttpClient, async requests, http/2 and http/3.
- 10.08jdbcconnections, prepared statements, transactions and pools.
- 10.09json and xmlparsing and writing both, plus the new json api on the way.
- 10.10security and cryptohashing, signing, encryption, and a TLS handshake, step by step.
- 11.01reflectionClass, Field, Method, and why setAccessible stopped working.
- 11.02annotationsretention, targets, and what an annotation actually is at runtime.
- 11.03annotation processingcode that runs inside javac. how lombok and mapstruct work.
- 11.04dynamic proxiesfake objects that intercept every call. spring's favourite trick.
- 11.05method handles and varhandlesfast, typed references to methods and fields.
- 11.06invokedynamicthe bytecode that powers lambdas, string concat and records.
- 11.07the class-file apigenerate and transform .class files with a real api.
- 11.08ServiceLoaderplugins without a framework.
- 12.01the jdk toolboxjavac, jar, javap, jdeps, jcmd, jdb. what's in bin/ and why.
- 12.02modulesmodule-info.java, requires, exports, opens. strong encapsulation.
- 12.03classpath to module pathunnamed modules, automatic modules, and migrating for real.
- 12.04jar, jlink, jpackagefrom a jar to a tiny custom runtime to a native installer.
- 12.05maventhe pom, the lifecycle, and how dependency conflicts get resolved.
- 12.06gradletasks, the task graph, and the kotlin dsl.
- 12.07testing with junitjunit 6, assertions, parameterized tests, mocks and testcontainers.
- 12.08code quality toolserror prone, spotbugs, nullaway and jspecify.
- 12.09javadocdoc comments, @snippet, and markdown docs.
- 12.10the ecosystem mapspring, quarkus, micronaut, jakarta ee, kotlin. who does what.
- 13.01JVM architectureclass loaders, runtime data areas, execution engine. the whole map.
- 13.02the class fileCAFEBABE, the constant pool, and every byte of a tiny .class.
- 13.03bytecodea stack machine. watch the operand stack while a method runs.
- 13.04the five invoke instructionsinvokestatic, virtual, interface, special, dynamic. who calls what.
- 13.05class loadingload → link → initialize. and the exact moments a class gets initialized.
- 13.06class loadersbootstrap, platform, app. delegation, and why two loaders = two classes.
- 13.07the interpreter and the JITtiered compilation: how hot code climbs from tier 0 to C2.
- 13.08JIT optimizationsinlining, escape analysis, loop tricks, and deoptimization.
- 13.09object layoutmark word, class pointer, fields, padding. and compact headers.
- 13.10how locks work insidelightweight locking, inflation, and what happened to biased locking.
- 13.11safepointshow the JVM stops every thread, and why your latency spiked.
- 13.12AOT, Leyden and native imagesCDS, the AOT cache, and starting fast.
- 14.01the JVM's memory mapheap, stacks, metaspace, code cache. what lives where.
- 14.02allocation and TLABsnew is usually just a pointer bump. here's why it's so fast.
- 14.03reachabilityGC roots, and soft, weak and phantom references.
- 14.04how garbage collection worksmark, sweep, compact, copy. and tri-color marking.
- 14.05generational collectionmost objects die young. eden, survivors, and the old generation.
- 14.06serial and parallelthe stop-the-world collectors, and when they're still the right call.
- 14.07G1regions, remembered sets, mixed collections. the default collector.
- 14.08ZGCcolored pointers and load barriers. sub-millisecond pauses.
- 14.09Shenandoahconcurrent compaction with forwarding pointers.
- 14.10choosing a collectorthroughput, latency, footprint. pick two.
- 14.11reading GC logs-Xlog:gc and what all those numbers mean.
- 14.12memory leaksyes, java leaks. heap dumps, dominators, and the usual suspects.
- 14.13native memorythe memory the heap doesn't count. NMT and direct buffers.
- 15.01measuring performanceaverages lie. percentiles, and coordinated omission.
- 15.02microbenchmarks with JMHdead code elimination ate your benchmark. how to not get fooled.
- 15.03flight recorderJFR events, always-on profiling, and mission control.
- 15.04profiling and flame graphsasync-profiler, safepoint bias, and reading a flame graph.
- 15.05the JVM in containersergonomics, memory limits, and the flags that matter.
- 15.06mechanical sympathycache lines, false sharing, and why arrays beat linked lists.
- 15.07the foreign function and memory apicall C and manage off-heap memory, safely.
- 15.08jnithe old way to call native code, and why it's being fenced in.
- 15.09the vector apiSIMD from java: one instruction, many lanes.
- 16.01creating and destroying objectsitems 1–9: factories, builders, singletons, and not leaking.
- 16.02methods common to all objectsitems 10–14: equals, hashCode, toString, clone, compareTo.
- 16.03classes and interfacesitems 15–25: accessibility, immutability, composition, interfaces.
- 16.04genericsitems 26–33: raw types, wildcards, and typesafe containers.
- 16.05enums and annotationsitems 34–41: enums over ints, EnumSet, EnumMap, @Override.
- 16.06lambdas and streamsitems 42–48: lambdas, method refs, and using streams judiciously.
- 16.07methodsitems 49–56: validation, defensive copies, overloading, optionals.
- 16.08general programmingitems 57–68: scope, libraries, floats, boxing, strings, naming.
- 16.09exceptionsitems 69–77: when to throw, what to throw, and never ignoring them.
- 16.10concurrencyitems 78–84: synchronization, executors, and thread safety docs.
- 16.11serializationitems 85–90: mostly, don't. and if you must, use a proxy.
- 17.01HashMap, line by linehash spreading, (n-1) & hash, the resize split, and treeification.
- 17.02ConcurrentHashMap internalsCAS on empty bins, locked bin heads, and cooperative resizing.
- 17.03the string poolliterals, intern(), and every == trap in one place.
- 17.04string concatenation internalsfrom StringBuilder to invokedynamic and StringConcatFactory.
- 17.05the integer cachewhy -128..127, and how to make it bigger.
- 17.06singletons and double-checked lockingthe half-constructed object, and the three ways to do it right.
- 17.07ThreadLocal internalsweak keys, the per-thread map, and the thread pool leak.
- 17.08ThreadPoolExecutor internalsthe ctl field: run state and worker count in one int.
- 17.09how lambdas are compiledno anonymous classes. invokedynamic and LambdaMetafactory.
- 17.10virtual threads, insidecontinuations, mounting, unmounting, and pinning.
- 17.11ArrayList vs LinkedList, measuredbig-O says one thing, the CPU cache says another.
- 17.12the OutOfMemoryError zooevery OOM message, what it means, and what to do.
- 17.13equals and hashCode trapsmutable keys, inheritance, and the object that vanished from a set.
- 17.14class loader leakshow redeploying an app leaks an entire copy of it.
- 18.01valhalla: value objectsobjects without identity, flattened into arrays. preview in jdk 28.
- 18.02leyden: starting fastAOT caches today, AOT code next.
- 18.03amber: the language keeps movingderived record creation, and what happened to string templates.
- 18.04loom: what's leftstructured concurrency going final, and beyond.
- 18.05panama and babylonvectors, native code, and java on GPUs.
- 18.06what's nextthe json api, null-restricted types, CRaC, and how to follow along.