Enum.name(): the exact constant name
Enum.name() returns an enum constant's identifier exactly as declared. Unlike toString(), it cannot be overridden.
CKTIS / Java
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
Enum.name() returns an enum constant's identifier exactly as declared. Unlike toString(), it cannot be overridden.
Enum.ordinal returns an enum constant's zero-based declaration position. Do not treat it as a persistent identifier.
Use `add`, `contains`, and `remove` to manage one enum-based permission set in Java SE 21. Iteration follows the order of the enum declarations, not the order of insertion.
Create an initially nonempty, mutable set of constants from one enum type. Distinguish collector characteristics from a spliterator’s bit mask.
Create mutable sets of constants from one enum type, and tell apart a membership result from a report that the set changed.
EnumClass.values() returns an array of all constants of an enum in declaration order. Use it to visit them in a for loop.
ExecutionException is a checked exception thrown when retrieving the result of a task that terminated with an exception. It separates task failure from the code receiving the result; getCause() lets you inspect the underlying cause.
Create two pools with two workers each, compare their queue limits, and collect task results before calling `shutdown()` on both pools.
A pool of size 3 can handle at most three tasks concurrently. It does not make them start at the same instant. Additional tasks wait in a queue when all workers are busy.
Identify an annotated field, read its declared type, and assign a constructed dependency while respecting Java SE 21 access rules.
Learn how to establish a Flow subscription in Java SE 21, receive items with bounded demand, and distinguish normal completion, failure, and cancellation.
Flow.Publisher<T> describes a source of items received by subscribers. Its subscribe method connects a receiver to the source, while Flow.Subscription lets the receiver request items and cancel delivery.
Flow.Subscriber<T> receives items and terminal signals from a publisher. Its subscription lets it express demand through request(n), allowing the receiver to control how many items are delivered.
Flow.Subscription controls item delivery between a publisher and a subscriber. request(long n) increases demand, while cancel() ends reception without guaranteeing that delivery stops immediately.
ForkJoinPool executes tasks using work-stealing. Learn synchronous invoke, the shared commonPool, and the lifecycle rules for shutting down an owned pool with shutdown.
ForkJoinPool.commonPool() returns the shared fork/join pool, rather than creating a new pool for each call.
ForkJoinTask represents a task executed by ForkJoinPool. Learn scheduling with fork(), retrieving results with join(), and group execution with invokeAll() through an example that splits a sum into subtasks.
`Function.andThen` returns a composed function that runs the receiver first and passes its result to the `after` function.
`apply` takes one argument and returns the function's result. Use it to call a single function or run a previously composed chain of functions.
`compose` builds a function that runs `before` first and passes its result to the receiving function. `andThen` starts with the receiving function instead.
`Function.identity()` gives you a function that returns the same reference. As a collector finisher, it lets the accumulation container become the result unchanged.
Retrieve an asynchronous task’s result and distinguish a task failure from interruption, cancellation, a wait timeout, or a failure of the `invokeAll` call itself.
`Future.isDone()` checks whether a task is complete without waiting for it. It returns `true` even when the task threw an exception or was cancelled.
`HashSet.add(E)` returns `true` when it inserts a new element and `false` when the set already contains an equal element.