Fluent builder with self type
A generic self type keeps subclass-specific methods available after inherited fluent calls. The terminal `build()` call creates a separate product from the builder’s current state.
CKTIS / Knowledge base
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
A generic self type keeps subclass-specific methods available after inherited fluent calls. The terminal `build()` call creates a separate product from the builder’s current state.
Functions and functional interfaces in Java: Java represents behavior with methods and with lambdas or method references targeted to a functional interface having one abstract method.
Java can infer a generic method’s type arguments from the call arguments and, where applicable, the expected result type. Boxing lets an `int` argument take part in such a call as an `Integer`, not as a primitive type argument.
Generics in Java: Generics provide compile-time checking, while type erasure removes most type arguments and inserts casts or bridge methods; generic method inference derives arguments from parameters and the target type.
An `Object[]` alias lets a `List<Integer>` replace a `List<String>` in a varargs array. The store succeeds, and no exception occurs unless the element is read as a `String`.
I/O and serialization in Java: Java I/O covers InputStream/OutputStream bytes, Reader/Writer characters with Charset, NIO files through Path/Files, and Serializable object graphs through ObjectOutput and ObjectInput.
Iterators and traversal in Java: Iterable supplies the Iterator used by enhanced for; Iterator advances with hasNext/next and may remove the last returned element through optional remove.
Learn which writes other threads may see in Java SE 21, why volatile does not make updates atomic, and how to reason about double-checked locking and VarHandle modes.
Linear search in Java: Linear search in Java examines elements in sequence until a match; List.indexOf uses equals and returns the lowest matching index or -1.
Loops and iteration in Java: Java provides while with a pre-test, do-while with a post-test, basic for, and enhanced for translated for arrays or Iterable sources.
Use an access-ordered `LinkedHashMap` to evict the least recently accessed entry when the cache exceeds its size limit, rather than evicting the first entry inserted.
References, copies, and memory in Java: In Java a reference variable denotes an object, so assignment or argument passing copies the reference rather than copying the object itself.
Modules and their boundaries in Java: The Java module system groups packages in a named module described by module-info.java; requires controls readability, exports type access, and opens deep reflection.
Numeric types and arithmetic in Java: Java has integral byte, short, int, long, and char plus floating-point float and double; integer arithmetic wraps at fixed width, while float and double follow IEEE 754.
A copy constructor creates a new instance from an existing one. A shallow copy still shares nested objects, while a deep copy separates the mutable state covered by the copy contract.
Java object model: Java’s object model combines single class inheritance, multiple interfaces, and composition; a static nested class has no enclosing instance, while an inner class does.
Performance and measurement in Java: Java performance depends first on algorithmic complexity and data structures, then on allocation, locality, synchronization, GC, and JIT optimization.
Java program entry point: The standard Java SE entry point is public static void main(String[] args); spelling the parameter as String... args has the same launcher signature.
Reactive streams and backpressure in Java: Java 21 exposes the reactive-streams contract through Flow.Publisher, Subscriber, Subscription, and Processor, with demand controlled by request(long).
Records and aggregate values in Java: A Java 21 record is a nominal, shallowly immutable aggregate class: its component list determines private final fields, public accessors, a canonical constructor, and equals, hashCode, and toString.
Records and sealed hierarchies: A record declares a nominal data carrier: components produce private final fields, accessors, a canonical constructor, and value-based equals, hashCode, and toString; a record is implicitly final.
Recursion and the call stack: Recursion occurs when a method calls itself directly or indirectly; every invocation owns a stack frame, so the algorithm needs a base case and progress.
Reductions and statistics: A reduction combines elements into a result, while IntSummaryStatistics gathers count, sum, min, max, and average in one traversal of an integer stream.
Reflection in Java: Reflection exposes runtime metadata and dynamic construction, field access, and method invocation through Class, Method, Field, and Constructor.