Predicate.or(): logical OR for predicates
Combine two predicates into one reusable condition. The second predicate is evaluated only when the first returns `false`.
CKTIS / Knowledge base
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
Combine two predicates into one reusable condition. The second predicate is evaluated only when the first returns `false`.
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.
PrintStream.print writes text or a value without adding a line separator. The print(String) overload prints null as the text "null".
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.
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.
Choose a class loader for an interface proxy, identify the intercepted method, and follow its arguments and result through two handlers to the real service.
`offer(E e)` tries to insert an element without waiting for space. It returns `true` if the element was added and `false` if no space is available.
Use `peek()` to read the head of a queue without removing it. If the queue is empty, the method returns `null`.
`Queue.poll()` retrieves and removes the head of a queue. If the queue is empty, it returns `null` rather than throwing an exception.
Several threads can read shared data at once, but writing requires exclusive access. Selecting a lock does not acquire it.
RecursiveTask<V> represents a fork/join task that returns a result of type V. Its compute() method defines the computation: handle a small problem directly or split it into subtasks and combine their results.
Distinguish blocking `lock()` from both `tryLock()` overloads, balance every successful acquisition with `unlock()`, and use distinct conditions on the same lock.
Reference provides operations on reference objects. Learn referent retrieval, reference clearing, and strong-reachability control in Java SE 21.
Learn when a reference can return its referent, what enters a reference queue, and how `reachabilityFence` keeps an object strongly reachable.
ReferenceQueue lets you retrieve registered reference objects after the garbage collector or an explicit enqueue() adds them. Learn the difference between nonblocking poll() and the blocking remove() variants.
Reference.reachabilityFence(ref) keeps an object strongly reachable at least until the call completes. It is useful when premature reclamation could interfere with an operation.
Array.newInstance creates arrays from a Class<?> object. It supports primitive types, reference types, and multiple dimensions.
In Java SE 21, `Field` and `Method` let you inspect metadata and annotations, change field values, and invoke methods. Finding a private member does not grant access, and `setAccessible(true)` is subject to module rules.
ResolverStyle controls how parsed fields become a date or time. The behavior of ResolverStyle.STRICT depends on the fields: for an ISO calendar date given as year, month, and day, it rejects February 29 in a non-leap year.
The RuntimeException(Throwable) constructor creates an unchecked exception, preserving the original cause and deriving its message from that cause.
`Scanner.close()` closes a scanner and can also close its input source. Learn when to call it and why shared standard input needs special care.
`Scanner.nextDouble()` reads the next input token as a primitive `double`. The scanner’s locale controls which decimal and grouping separators it recognizes.
Read the next token as an `int`, check whether it is valid before reading, and see why a following `nextLine()` can return an empty string.
`Scanner.nextLine()` returns the rest of the current line without its line separator. Immediately after `nextInt()`, the result can be an empty string.