Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Knowledge base

Knowledge base

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

Entries: 5788

Java

var — local variable type inference

`var` lets the compiler infer a local variable's type from its initializer. The type remains static and does not change with later assignments. In Java SE 21, `var` is a contextual keyword, not a type name.

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

volatile — field visibility between threads

volatile is a reserved keyword marking a field used for communication between threads. It provides visibility and happens-before ordering guarantees, but does not provide mutual exclusion or make operations such as count++ atomic.

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

when — an additional condition on a switch pattern

In Java SE 21, the contextual keyword when introduces an additional condition (a guard) after a case pattern in a switch statement or expression. The branch is selected only when the value matches the pattern and the guard evaluates to true.

Intermediate · Language target: Java SE 21. Neither the repository runtime version nor the production runtime version is attested.
Java

while — a pre-test loop

The while keyword introduces a loop that checks its condition before each execution of its body. The body may never execute; the condition must have type boolean or Boolean.

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

with — service providers in a module

In Java SE 21, `with` is a contextual keyword in the `provides` directive of a module declaration. It separates the service type from its provider list; outside that context, it can be an identifier.

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

yield — producing a value from a switch expression

The yield statement supplies a value to the nearest enclosing switch expression. It is useful in a block arm that executes several statements before producing its result. In Java SE 21, yield is a contextual keyword.

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

The null literal

The null literal denotes a reference that does not point to any object. It has the special null type and can be assigned to variables of reference types, but not to variables of primitive types.

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

main: practical reference

main: practical reference: The Java launcher invokes a public static void main(String[] args) method on the selected class after loading, linking, and class initialization.

Intermediate · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

AutoCloseable.close(): automatic resource cleanup

`close()` releases an object's resources. A try-with-resources statement calls it automatically, but the interface does not require a repeated call to have no effect.

Intermediate · Java SE 21
Java

List.add(E) — append an element to a list

`List.add(E)` appends one element to the existing list and returns `true` if the call completes normally. Not every list supports adding elements.

Intermediate · Java SE 21
Java

List.remove(Object): remove the first match

Remove the first occurrence of a value, such as a subscriber name, and use the `boolean` result to tell whether anything was removed. Contrast this with removal by index.

Intermediate · Java SE 21
Java

Overriding Object.toString()

Give an object a readable description and see how `println(Object)` prints it without an explicit call to `toString()`.

Intermediate · Java SE 21