`Matcher.matches()`: Match the entire region in Java
`Matcher.matches()` tests a regular expression against the entire current region, not just a substring. By default, the region covers the whole input.
CKTIS / Java
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
`Matcher.matches()` tests a regular expression against the entire current region, not just a substring. By default, the region covers the whole input.
Find the absolute value of a number, compare floating-point values within a tolerance, and handle the smallest integer values correctly.
Math.max returns the greater of two numbers. Learn its numeric overloads and its behavior for NaN and signed zero.
`Math.min` returns the smaller of two numeric values. Use it to keep an increasing priority from going above 5.
Math.round chooses the nearest integer, breaking ties toward positive infinity. The result type depends on the overload.
MessageDigest computes one-way hashes of data. Learn how to select SHA-256, process bytes, understand the reset after digest, and compare results with isEqual.
Look up an instance method by its signature, bind the receiver into a new handle, and compare an exact call with a call that can adapt compatible types.
Find the closest stored key below or above a search key, with or without including a key that compares equal.
Use `subMap`, `headMap`, and `tailMap` to select a key range, explicitly include or exclude its endpoints, and work with the original map rather than a copy.
NoSuchFieldException is a checked exception raised when a lookup cannot find a field with the specified name. With reflection, the search scope matters: getField searches public fields, while getDeclaredField searches fields declared directly by the given type.
Get a `Number` object's value as a primitive `double`. Whether the result is exact depends on the object's actual subtype and whether the value can be represented as a `double`.
Object.equals compares object identity by default. Overriding it lets a class define value equality.
`getClass()` returns the `Class` object for an object's runtime class, regardless of the variable's declared type. It lets you test for an exact class match, but it does not reveal a generic instance's type arguments.
Object.hashCode returns an int used by hash tables. Objects equal according to equals must have matching codes; the reverse does not hold.
Compare titles safely when either may be missing, then enforce a separate non-null requirement when generating a label.
Write an object to a `byte[]` and reconstruct it from trusted bytes generated by the same program. See why default serialization omits `transient` fields.
Combine two fields into an `int` hash code, see why Java autoboxes an `int` to `Integer`, and learn how `Objects.hash` differs from `Objects.hashCode`.
In Java SE 21, `Objects.requireNonNull` returns the same reference if it is not `null`, or throws an exception. It checks that an argument is present, not that its contents are valid.
Object.toString returns an object's text representation. Overriding it lets you provide readable text useful for diagnostics.
Guard shared state with one monitor, recheck the condition in a `while` loop, and remember that `notifyAll()` neither releases the lock nor hands it to a waiter.
OptionalDouble represents a double value or its absence. Learn how orElse differs from getAsDouble.
Optional.empty: practical reference: Optional.empty() returns an empty Optional<T> representing absence, with its type parameter inferred from the invocation context.
Optional.filter: practical reference: Optional.filter(predicate) returns an Optional describing a present value that satisfies the predicate, empty when it does not, and stays empty for an empty receiver.
Optional.flatMap: practical reference: Optional.flatMap(mapper) returns the Optional produced by the mapper without another wrapper for a present value, and returns empty for an empty receiver.