Oracle Java SE 21 key terms
Oracle Java SE 21 · Get comfortable with the vocabulary.
- java.time.LocalDate
- Related: DateTimeFormatter, Period
An immutable java.time class representing a date without a time zone or time of day, holding year, month and day. It is used for plain calendar dates such as birthdays or due dates.
- DateTimeFormatter
- Related: java.time.LocalDate, Period
A java.time class that defines how date-time objects are turned into text and how text is parsed back into date-time objects, using patterns, locales or predefined constants such as ISO_LOCAL_DATE.
- Period
- Related: Duration, java.time.LocalDate
A date-based amount expressed in years, months and days, used to add to or subtract from LocalDate values. Unlike Duration it works in calendar units rather than elapsed clock time.
- Duration
- Related: Period, java.time.LocalDate
A time-based amount measured in seconds and nanoseconds, typically combined with Instant or LocalTime. It measures elapsed clock time and cannot represent months or years.
- BigDecimal
An immutable, arbitrary-precision decimal number class used for exact arithmetic such as money calculations, where binary floating-point types like double would introduce rounding errors. Rounding behaviour is controlled with an explicit RoundingMode.
- Switch expression
- Related: Pattern matching for instanceof, Labeled break
A form of switch that yields a value instead of only running statements. It uses arrow labels, does not fall through, and must be exhaustive when the selector is an enum or sealed type.
- Pattern matching for instanceof
- Related: Switch expression, Sealed class
A language feature that lets a type-test expression declare a binding variable which is definitely assigned when the test succeeds, removing the need for an explicit cast on the next line.
- Labeled break
- Related: Enhanced for loop, Switch expression
A named label placed before a loop that allows break or continue to target an outer loop from inside a nested loop, controlling how far execution unwinds or skips.
- Enhanced for loop
- Related: Labeled break, List.of
The for-each statement that iterates arrays and Iterable objects without exposing an index or iterator. Structurally modifying the collection inside the loop usually throws ConcurrentModificationException.
- Sealed class
- Related: Record, Switch expression
A class or interface declared with sealed that restricts which types may extend or implement it. Permitted subtypes are named in a permits clause and must themselves be final, sealed or non-sealed.
- Record
- Related: Sealed class, equals/hashCode contract
A concise, immutable data-carrier class that automatically generates a canonical constructor, accessor methods, equals, hashCode and toString from its declared components. Records are implicitly final and cannot be extended.
- Default method
- Related: Abstract class, Functional interface
An interface method with a body marked default, letting interfaces gain behaviour without breaking existing implementors. When a superclass method and a default method conflict, the superclass method wins.
- Abstract class
- Related: Default method, Sealed class
A class that cannot be instantiated and may declare abstract methods that subclasses must implement. It can hold instance state and concrete methods, which distinguishes it from a pure interface.
- Checked exception
- Related: try-with-resources, Suppressed exception
An exception that subclasses Exception but not RuntimeException, which the compiler requires callers to catch or declare with a throws clause. It represents expected, recoverable conditions.
- try-with-resources
- Related: Checked exception, Suppressed exception
A try statement that declares one or more AutoCloseable resources and closes them automatically in reverse declaration order when the block exits, recording close failures as suppressed exceptions.
- Multi-catch
- Related: Checked exception, Suppressed exception
A single catch clause handling several unrelated exception types separated by the pipe character. Its parameter is implicitly final and its static type is the least upper bound of the listed types.
- Suppressed exception
- Related: try-with-resources, Checked exception
An exception attached to a primary exception when it arises during resource cleanup instead of replacing the original. It is retrieved with getSuppressed rather than being silently lost.
- equals/hashCode contract
- Related: Record, Comparator
The rule that objects equal according to equals must return the same hashCode, so hash-based collections can locate them. Breaking it causes duplicate keys and failed lookups in HashMap and HashSet.
- Comparable
- Related: Comparator
An interface whose compareTo method defines a class's natural ordering, used by sorted collections and by Arrays.sort and Collections.sort for arrays and lists of that type.
- Comparator
- Related: Comparable, Functional interface
A functional interface whose compare method supplies an ordering defined outside the class, allowing sorting of types that are not Comparable and composition with thenComparing and reversed.
- List.of
- Related: Enhanced for loop, Collector
A static factory returning an unmodifiable, null-rejecting List of the supplied elements. It throws NullPointerException at creation and UnsupportedOperationException on any attempted mutation.
- Functional interface
- Related: Method reference, Comparator
An interface with exactly one abstract method, which can therefore be implemented by a lambda expression or method reference. It may still declare default and static methods.
- Method reference
- Related: Functional interface, Optional
A compact syntax such as String::length or System.out::println that points at an existing method and implements a functional interface without writing a lambda body.
- Terminal operation
- Related: Collector, Optional
A stream operation such as collect, forEach, count or reduce that starts pipeline processing and consumes the stream. Intermediate operations like filter and map do nothing until one is invoked.
- Optional
- Related: Terminal operation, Method reference
A container that either holds a value or is empty, intended mainly as a return type signalling a possibly missing result instead of null. It is not meant for fields or method parameters.
- Collector
- Related: Terminal operation, Functional interface
An object describing how to accumulate stream elements into a result such as a list, map or joined string. Instances usually come from the Collectors factory methods and are passed to collect.
- module-info.java
- Related: jlink, JAR manifest
A module descriptor declaring a module's name, the packages it exports, the modules it requires and any services it uses or provides. It sits at the root of the module's source tree.
- jlink
- Related: module-info.java
A JDK tool that assembles a custom runtime image containing only the modules an application actually needs, producing a smaller, self-contained distribution without a full JDK.
- JAR manifest
- Related: module-info.java, jlink
The META-INF/MANIFEST.MF file inside a JAR holding metadata such as Main-Class for executable jars, version information and class path entries read by the java launcher.
- ExecutorService
- Related: CompletableFuture, synchronized
A concurrency abstraction that manages a pool of worker threads and accepts tasks submitted as Runnable or Callable, separating task submission from thread creation and lifecycle management.
- volatile
- Related: synchronized, CompletableFuture
A field modifier guaranteeing that reads and writes go to main memory and that other threads observe the latest value, giving visibility and ordering but not atomicity for compound actions.
- synchronized
- Related: volatile, ExecutorService
A keyword that acquires a monitor lock for a block or method, providing mutual exclusion and a happens-before relationship so only one thread at a time runs the guarded code.
- CompletableFuture
- Related: ExecutorService, volatile
A class representing an asynchronous result that can be completed later, supporting chained transformations and combinations through methods such as thenApply, thenCompose and exceptionally.
- Path
- Related: Files, Charset
The java.nio.file interface representing the hierarchical location of a file or directory, independent of the file's content. Instances are created with Path.of and combined via resolve or relativize.
- Files
- Related: Path, Charset
A utility class of static methods for common file operations, such as reading all lines, writing text, copying, moving, testing existence and walking a directory tree.
- Charset
- Related: Files, Path
A named mapping between characters and bytes. Reader and Writer classes accept one so text is decoded and encoded correctly; for example Files.readString assumes UTF-8 by default.
- PreparedStatement
- Related: ResultSet, Auto-commit
A precompiled SQL statement with parameter placeholders filled by typed setter methods, giving protection against SQL injection and better reuse than a plain Statement.
- ResultSet
- Related: PreparedStatement, DataSource
A cursor over the rows returned by a query. You advance it with next and read columns by index or label; it is closed along with its statement by try-with-resources.
- DataSource
- Related: Auto-commit, PreparedStatement
A factory for database connections, usually configured and pooled by a container, preferred over DriverManager because it supports connection pooling and is not tied to a hard-coded URL.
- Auto-commit
- Related: PreparedStatement, DataSource
The default JDBC mode in which each statement forms its own transaction. Disabling it lets several statements be grouped and explicitly committed or rolled back as one unit.