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

Optional.ifPresent: practical reference

Optional.ifPresent: practical reference: Optional.ifPresent(action) invokes the Consumer exactly once with the present value and performs no action for an empty Optional.

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

Optional.ifPresentOrElse: practical reference

Optional.ifPresentOrElse: practical reference: Optional.ifPresentOrElse(action, emptyAction) invokes the Consumer with the present value or runs the Runnable when absent; exactly one branch is selected.

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

Optional.map: practical reference

Optional.map: practical reference: Optional.map(mapper) applies the Function to a present value and wraps a non-null result, while a null result or empty receiver yields Optional.empty().

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

Optional.of: practical reference

Optional.of: practical reference: Optional.of(value) creates an Optional with a necessarily present non-null value and preserves its inferred generic type.

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

Optional.ofNullable: practical reference

Optional.ofNullable: practical reference: Optional.ofNullable(value) returns Optional.empty() for null and retains a non-null value in the same way as Optional.of.

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

Optional.orElse: practical reference

Optional.orElse: practical reference: Optional.orElse(other) returns the present value, or the supplied other object when the Optional is empty.

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

Optional.orElseGet: practical reference

Optional.orElseGet: practical reference: Optional.orElseGet(supplier) returns the present value and invokes the supplier only for an empty Optional, returning its result.

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

Optional.orElseThrow: practical reference

Optional.orElseThrow: practical reference: Optional.orElseThrow returns the present value; the no-argument form throws NoSuchElementException when empty, while the supplier form throws the supplied exception.

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

OutOfMemoryError — memory allocation failure

OutOfMemoryError signals a JVM memory allocation problem. It is a subtype of Error, not Exception, and needs no throws declaration. It does not automatically mean a memory leak or merely a full Java heap.

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

PhantomReference — phantom references

PhantomReference<T> supports notification of changes in an object's reachability without exposing it through get(). It works with ReferenceQueue; the example demonstrates deterministic, manual enqueueing.

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

Predicate.test() — evaluating a condition

Use `test(T t)` to check a condition against one input. It returns the primitive `boolean` value `true` if the input meets the condition, or `false` if it does not.

Basic · Java SE 21
Java

PrintStream.print — output without ending the line

PrintStream.print writes text or a value without adding a line separator. The print(String) overload prints null as the text "null".

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

PrintStream.printf — formatted output

PrintStream.printf writes data according to a format string, for example to System.out. It controls how numbers and text are presented and allows an explicit locale.

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

PriorityBlockingQueue — a concurrent priority queue

PriorityBlockingQueue is a thread-safe, logically unbounded priority queue. put inserts without waiting for space, while take removes the least available element and waits when the queue is empty.

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