skip to content
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.

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