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

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
Java

Checking, adding, and removing set elements in Java

Check whether an element belongs to a set and tell whether an addition or removal changed it. Use `LinkedHashSet` to track completed lessons without duplicates and in insertion order.

Intermediate · Java SE 21