Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Java

Knowledge base — Java

Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.

Entries: 813

Java

Anonymous classes in Java

An anonymous class lets you define an interface implementation or a subclass and create an instance of it in the same expression.

Intermediate · Java SE 21
Java

Array initializer

An array initializer creates an array from values enclosed in braces. The number of entries determines its length.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

Java arrays: declaration, indexing, and length

Declare and create arrays, read and replace elements by index, and distinguish array length from list size. See what `new List[2]` creates and how to avoid raw `List` in new code.

Intermediate · Java SE 21
Java

Java class literals: `TypeName.class`

A `.class` literal gives you the object that represents a named type. Use it to filter values, specify an `EnumMap` key type, select a monitor, or configure a field updater.

Intermediate · Java SE 21
Java

Capturing effectively final local variables

A lambda can capture a local variable without the `final` modifier if it is effectively final. A fixed reference does not make the object it points to immutable.

Intermediate · Java SE 21
Java

Enum constant-specific class body

In Java SE 21, an `enum` constant can pass arguments to the enum constructor and have its own class body to define its behavior.

Intermediate · Java SE 21
Java

Generic type parameter bounds

Bounds restrict which types can be used as generic arguments. Learn how to preserve a builder’s concrete type, compare values through a supertype, and require several bounds at once.

Intermediate · Java SE 21
Java

Hexadecimal integer literal

A hexadecimal integer literal expresses a value in base 16 using the prefix 0x or 0X. The suffix L selects long; without a suffix, the literal has type int.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

Java integer literals: the L suffix

Write `10000000001L` to make a `long` literal. Without the suffix, the value is too large for `int`, even if the destination variable is declared `long`.

Intermediate · Java SE 21
Java

Java’s `L` integer literal suffix

`0L` is zero of type `long`, while `0` is zero of type `int`. That difference matters for overload selection, arithmetic, and defaults that must be `Long`.

Advanced · Java SE 21
Java

Local class declaration in Java

A local class is a named nested class declared, for example, in a method block. The scope of its name does not limit the lifetime of its instances.

Intermediate · Java SE 21
Java

Method overloading

Method overloading lets several methods share a name while using different parameter lists. The compiler selects an overload using the arguments and their compile-time types, rather than the runtime classes of argument objects.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

Multi-catch: shared exception handling

The catch (A | B e) syntax handles different exception types in one block. Alternative types must not have a subtype relationship, and the parameter e is implicitly final.

Intermediate · Java SE 21; repository runtime, production runtime not attested
Java

Nested classes and interfaces in Java

Distinguish static nested classes from inner classes, expose builder steps through public interfaces, and give a nested LRU cache its own type parameters.

Intermediate · Java SE 21
Java

Raw `List` and `ArrayList`

Raw `List` and `ArrayList` bypass compile-time element-type checks. Assigning a raw list to `List<String>` neither validates its contents nor recovers a type argument.

Intermediate · Java SE 21
Java

Compact canonical constructor for a record

In Java SE 21, a record’s compact canonical constructor validates or normalizes arguments before Java assigns their values to the component fields.

Advanced · Java SE 21
Java

Recursive type bounds in Java

A bound such as `T extends Base<T>` lets base-class methods return a concrete subclass type without requiring every subclass to supply its own type.

Advanced · Java SE 21
Java

Regular expression syntax in Java

Read and write Java 21 regex patterns using character classes, quantifiers, groups, anchors, escapes, and inline flags.

Basic · Java SE 21
Java

Static initializer block

A static { ... } block executes statements during class initialization, not whenever an object is created. Use it to prepare static fields when initialization needs several statements.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

Static nested classes in Java

A static nested class belongs to an enclosing type, but you do not need an instance of that type to create a nested object.

Intermediate · Java SE 21
Java

Switch expression with arrow rules

In Java SE 21, a `switch` expression selects a value. Arrow rules prevent fall-through and let several enum constants share one `case` label.

Advanced · Java SE 21