Java Cheat Sheet

This section documents the current Java release line, with Java 25 LTS as the reference point (no specific patch version is pinned), as published at the Java developer portal, the Java Tutorials, and the Java SE API specification — which are the references these pages are written and verified against.

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

This section’s bibliography lists the reference material consulted while preparing these pages.

A single-page, colour-coded summary of the Java essentials — the javac/java/jar one-liners, the eight primitives and var, operator precedence, String/text blocks/formatting, control flow including arrow-form switch expressions and case patterns, arrays and java.util.Arrays, class/constructor/static syntax, inheritance with @Override and the Object methods, interfaces with default/static/private methods, record and sealed, enum, nested classes and the four method-reference forms, generics with the PECS rule and erasure, pattern matching (instanceof, switch, record deconstruction, when), the built-in annotations, exceptions with try-with-resources, Optional, the collections hierarchy with factory methods and sequenced collections, the stream pipeline and key Collectors, the java.util.function interfaces and their composition, wrapper/autoboxing pitfalls and BigDecimal, the java.time core types, NIO.2 Path/Files, Pattern/Matcher, threads with synchronized/volatile, executors and CompletableFuture, virtual threads, packages and module-info clauses, the JDK tool list with a Maven/Gradle skeleton, and JUnit 5 (@Test, lifecycle, @ParameterizedTest) with Mockito (mock/when/verify) — handy for quick memorization or as a printable desk reference.

For the full explanation, every option, and additional examples, see the dedicated pages:

Getting started — Getting Started.

Modern language features — Pattern Matching, and Annotations & Reflection.

Modularity, packaging & tooling — Packages & Modules, and Build & Tooling.