Loading…
Loading…
Topic
Articles and problems tagged Modern Java.
Record patterns for the OCP 21 exam: deconstructing records with instanceof, the component rules, how nested pattern types match at run time, nested record patterns, var and generics in patterns, record patterns in switch with when guards, exhaustiveness, and what changed in Java 22 to 25.
Sealed classes and interfaces for the OCP 21 exam: sealed and permits, the final, sealed or non-sealed rule for direct subclasses, same package or module, when permits can be omitted, nested subclasses, sealed interfaces, and exhaustive pattern-matching switches.
The Java 21 pattern switch for the OCP exam: type patterns on any reference type, when guards, dominance and branch order, exhaustive statements, case null and case null, default, record patterns, and sealed types without a default.
The OCP Java 21 rules for switch: allowed selector types, compile-time constant case values, colon versus arrow labels, fall-through and break, switch expressions with consistent result types, semicolons, yield, exhaustiveness and qualified enum constants.
Decision-making for the OCP Java 21 exam: statements and blocks, if, else if and else, braces versus indentation, the dangling else, pattern matching with instanceof, pattern variables, conditions after &&, null handling, supported types and flow scoping.
Variable rules for the OCP Java 21 exam: legal identifiers and reserved words, declaring several variables in one statement, final locals, definite assignment, default values for fields, method parameters, every rule of var, and Java 22's unnamed variables.
Java's data types for the OCP 21 exam: the eight primitives and their ranges, numeric literals in four bases, underscore rules, primitives versus references, wrapper classes with valueOf and parseXxx, and text blocks with incidental whitespace and escapes.
Describing C data with FFM memory layouts: value layouts and C types, struct and union layouts, alignment and padding, sequences, layout paths, var handles with base offsets, offset and slice handles, pointers with target layouts, and atomic access modes.
Master pattern matching for switch (Java 21+): type patterns, record patterns, unnamed variables, case null, guards with when, exhaustiveness rules, dominance, constant labels, MatchException, and scope and fall-through rules, with runnable examples.
Java sealed classes and interfaces (final since Java 17) let you list exactly which classes may extend a type. Learn sealed, permits, final and non-sealed, the placement rules, exhaustive switch without default, records and enums in sealed hierarchies, and when to choose sealed types.
A working tour of the String API (strip, startsWith, replace, indexOf ranges, formatted, lines, isBlank and more), how to read the Javadoc, iterating over code points correctly, building strings fast with StringBuilder, and writing multi-line text with text blocks.
Choose among many values with Java's switch expression: the arrow syntax, selector types, several labels per case, enums without prefixes, exhaustiveness and default, blocks with yield, throwing from a case, and handling null with case null.
How to declare and initialize variables in Java, the naming rules, why the compiler rejects uninitialized variables, local type inference with var, constants with final and static final, and a first look at enumerated types.