Java Reference
|
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. |
Welcome to the Java reference. Java is a statically-typed, class-based, object-oriented language — it compiles to platform-neutral bytecode that runs on the Java Virtual Machine ("write once, run anywhere"), favours explicit types and clear structure, and ships a large standard library. This section documents the current Java release line, with Java 25 LTS as the reference point (no specific patch version pinned), framework-agnostic (not Spring, Jakarta EE, or JavaFX), written and verified against dev.java, the Java Tutorials, and the Java SE 25 API specification.
If you are new to Java, read Getting Started first, then the Language fundamentals pages in order, followed by Object-oriented programming — from there the remaining groups (modern language features, the core library APIs, concurrency, modularity and tooling, and testing) can be read in any order as you need them. For the sibling framework reference, see SpringBoot Reference.
What’s covered
Getting started
-
Getting Started — what Java is, the JDK vs. the JRE, installing a JDK,
javac/java, the single-file source launcher, JShell, the source-to-bytecode-to-JVM model, and the six-month release cadence / LTS / preview features.
Language fundamentals
-
Lexical Structure & Style — source-file structure, identifiers and reserved words, literals, the three comment forms, statements and blocks, and the standard code conventions.
-
Primitive Types & Variables — the eight primitives and their ranges, literals,
finalconstants,varlocal-variable type inference, widening/narrowing conversions, and integer overflow. -
Operators & Expressions — arithmetic, relational, logical (short-circuit), bitwise and shift operators, the conditional operator,
instanceof, and operator precedence. -
Strings & Text —
Stringimmutability and the string pool,==vs.equals, the common methods,StringBuilder, text blocks, and string formatting. -
Control Flow —
if/else, the loop forms,break/continueand labels,switchstatements, and arrow-formswitchexpressions. -
Arrays — declaration and allocation, iteration, multidimensional and jagged arrays,
java.util.Arrays, and varargs.
Object-oriented programming
-
Classes & Objects — fields, methods, constructors and constructor chaining,
this, object creation and garbage collection,staticmembers, and access modifiers. -
Methods & Parameters — return values, pass-by-value, overloading and overload resolution, varargs, recursion, and the utility APIs.
-
Inheritance & Polymorphism —
extendsandsuper, overriding vs. overloading, dynamic dispatch,abstractandfinal, and thejava.lang.Objectmethods. -
Interfaces —
default/static/privateinterface methods, functional interfaces,Comparablevs.Comparator, and default-method resolution. -
Records & Sealed Classes — record components and the compact constructor, generated members, and
sealed/permits/non-sealedhierarchies. -
Enums — enum constants, fields and methods, constant-specific bodies, and
EnumSet/EnumMap. -
Nested & Anonymous Classes — static nested, inner, local, and anonymous classes, and when each still fits.
-
Lambdas & Method References — lambda syntax and target typing, effectively-final capture, the four method-reference kinds, and lambda vs. anonymous class.
-
Generics — generic classes and methods, bounded type parameters, wildcards and the PECS rule, and type erasure.
Modern language features
-
Pattern Matching — pattern matching for
instanceof, type patterns inswitch, record deconstruction patterns, and guarded patterns. -
Annotations & Reflection — the built-in annotations, declaring a custom annotation with meta-annotations, and reading members at runtime via
java.lang.reflect.
Core library APIs
-
Exceptions — the
Throwablehierarchy, checked vs. unchecked,try/catch/finally, multi-catch, try-with-resources, custom exceptions, and exception chaining. -
Optional — modelling the absence of a value, the transform and unwrap methods, the primitive variants, and the anti-patterns.
-
Collections Framework — the interface hierarchy and implementations, iterators, the utility class and factory methods, sequenced collections, and the
equals/hashCodecontract. -
Streams & Collectors — the lazy pipeline, the intermediate and terminal operations,
Collectors, primitive and parallel streams. -
Functional Programming — the
java.util.functioninterfaces, composition, higher-order functions and currying, and refactoring imperative loops. -
Numbers & Math — wrapper classes and autoboxing pitfalls,
Math,BigInteger/BigDecimal, parsing and formatting, and floating-point caveats. -
Dates & Times — the
java.timetypes,Duration/Period, formatting and parsing, time zones, and legacy interop. -
I/O & Files —
java.iostreams and readers,Scanner, and the NIO.2Path/FilesAPI. -
Regular Expressions —
PatternandMatcher, groups and named groups, flags, theStringconveniences, and backtracking pitfalls.
Concurrency
-
Concurrency Basics — creating threads, the thread lifecycle,
synchronizedandvolatile, the Java Memory Model, and the classic hazards. -
High-Level Concurrency — executors and thread pools,
FutureandCompletableFuture, the concurrent collections and atomics, and the locks and synchronizers. -
Virtual Threads — platform vs. virtual threads, the creation APIs, carrier threads and pinning, and a note on structured concurrency.
Modularity, packaging & tooling
-
Packages & Modules — packages and imports, the four access levels, and the Java Platform Module System (
module-info.java,requires/exports/opens). -
Build & Tooling — the core JDK tools, a technology-neutral tour of Maven and Gradle, the common build plugins (testing, coverage, static analysis, SonarQube, reporting, publishing to Maven Central), and generating API docs with
javadoc. -
Javadoc — doc comments, block and inline tags, package and module documentation, documentation inheritance, and worked examples.
Testing & reference
-
Unit Testing with JUnit 5 & Mockito — JUnit Jupiter (assertions, the lifecycle, parameterized tests) and Mockito (
mock/when/verify,@Mock/@InjectMocks, spies and captors). -
Cheat Sheet (PDF) — a single-page, printable summary of everything in this section, with a downloadable PDF.
Bibliography
-
dev.java — the destination for Java developers (Oracle), and its learning portal dev.java/learn; a primary source for concept framing and the topic taxonomy of this section.
-
The Java Tutorials — the long-standing trail-based tutorials (Learning the Java Language, Essential Java Classes, Collections, Generics, Concurrency, Date-Time, Regular Expressions, Reflection).
-
the JDK 25 documentation, including the Java Language Updates and the core-libraries guides.
-
the Java SE 25 API specification (Javadoc) — the reference every API type and method in this section links to.
-
The Java Language Specification, Java SE 25 — the authoritative reference for the language-level pages.
-
OpenJDK and the JEP index — the design rationale for records, sealed classes, pattern matching, text blocks,
switchexpressions, virtual threads, and the module system. -
the JUnit 5 User Guide — the primary source for the unit-testing page.
-
the Mockito documentation — the primary source for the mocking part of the unit-testing page.
-
Ogihara, Mitsunori. Fundamentals of Java Programming. Springer, 2018. ISBN 978-3-319-89490-4 (print) / 978-3-319-89491-1 (eBook). Consulted as part of the bibliography for this section, not the primary source (predates Java 8 lambdas/streams and all later language features) — see the publisher’s book page and link.springer.com.
-
Charatan, Quentin, and Aaron Kans. Java in Two Semesters: Featuring JavaFX, 4th ed. Springer (Texts in Computer Science), 2019. ISBN 978-3-319-99419-2 (print) / 978-3-319-99420-8 (eBook). Consulted as part of the bibliography for this section, not the primary source (covers up to Java 8; its JavaFX chapters are outside this section’s scope) — see the publisher’s book page and link.springer.com.
-
Urma, Raoul-Gabriel, Mario Fusco, and Alan Mycroft. Modern Java in Action. Manning, 2019 (ISBN 9781617293566). Consulted as part of the bibliography for this section, not the primary source (covers up to Java 11) — see the publisher’s book page and manning.com.
The three books above are consulted references, not the primary source for this section; on any discrepancy, or wherever a book is silent on a feature introduced after it was written, the official documentation wins.