I/O and serialization in Java
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.
CKTIS / Java
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
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.
Scope and lifetime: Lexical scope determines where a name is visible, while object lifetime follows reachability; try-with-resources closes a resource deterministically.
Security and password hashing: Java security requires trust-boundary validation, least privilege, and platform cryptography; password hashing should use a slow KDF rather than raw MessageDigest.
Sorting and comparators: List.sort and object Arrays.sort order stably by a Comparator, so elements equal under the order retain their prior encounter order.
Staged builder through interfaces splits object construction into typed steps. Each stage-transition method returns the next stage's interface, so an ordinary call chain exposes `build()` only after the required inputs have been supplied. This does not replace runtime validation of those inputs.
Java Stream pipelines: A Stream is a single-use lazy pipeline of a source, intermediate operations, and a terminal operation; elements flow only when the terminal requests a result.