Class.getName() — type names in Java
`Class.getName()` returns the name of the represented type. For ordinary classes and interfaces, this is the binary name; arrays use a different notation.
CKTIS / Java
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
`Class.getName()` returns the name of the represented type. For ordinary classes and interfaces, this is the binary name; arrays use a different notation.
Get a readable type or exception label without package or enclosing-class names.
Use `Class.isInstance` when the target type is held in a `Class<?>` variable and you want to check an object before casting it.
Inspect an object's actual class in Java SE 21, read its name, find declared fields and constructors, and distinguish direct annotations from inherited ones.
Read a type's name, look up fields and methods declared directly on it, and create an instance with a selected constructor without confusing discovery with access.
Cleaner registers a cleanup action. Invoke it explicitly through Cleanable.clean(); automatic execution is a fallback mechanism.
CodingErrorAction controls how a charset decoder or encoder handles coding errors. REPORT exposes an error to the caller, while REPLACE substitutes the configured replacement and continues processing. Malformed input and unmappable characters have independently configured policies.
`Collection.isEmpty()` returns `true` when a collection has no elements and `false` otherwise. It does not change the collection.
Create a stream pipeline from a collection that can run in parallel. Learn why execution mode and result order are separate and when to measure performance.
Use `Collection.size()` to read a collection’s element count as an `int`. If you only need to know whether the collection is empty, use `isEmpty()` instead.
Collection.spliterator() returns an object for traversing collection elements and potentially partitioning the work. Learn the default implementation, size characteristics, and limitations around modification and concurrency.
Collections.reverseOrder creates a comparator reversing natural ordering or the ordering of a supplied comparator.
Sort an existing list by its elements’ natural order or by a comparator. Both overloads modify the same list and preserve the relative order of elements that compare as equal.
`Collections.swap` exchanges the elements at two indices in the same list. It does not create a new list and requires the list to support `set`.
Collections.synchronizedList adds synchronization to a list. Traversal and sequences of dependent operations require additional locking.
Wrap an existing map to synchronize individual method calls. When traversing a view, lock the returned map for the entire traversal, not the view itself.
Create streams from collections, distinguish execution mode from element order, and use `List::stream` to flatten nested lists.
Block writes through a list view without freezing the source. To keep later edits to the source out of the view, wrap a private copy instead.
Define a stream collector that creates working state, adds elements, merges partial results, and converts the state into a final value.
Collectors.collectingAndThen: practical reference: Collectors.collectingAndThen adapts a downstream collector and applies a finishing function exactly once to its completed result; the returned collector does not retain IDENTITY_FINISH.
Collectors.counting: practical reference: Collectors.counting returns a collector equivalent to reducing every element to 1L and summing, so its result type is Long.
Collectors.groupingBy: practical reference: Collectors.groupingBy classifies each element by a key function and accumulates a Map from keys to group results; its overloads select the map supplier and downstream collector.
`Collectors.groupingByConcurrent` groups stream elements by key and can count each category without preserving the order in which elements are encountered.
Collectors.joining: practical reference: Collectors.joining concatenates CharSequence elements, optionally inserting a delimiter and surrounding the result with a prefix and suffix.