# Java 26 – Interview Questions & Answers

> A practical Q&A guide covering Collections, Concurrency, JVM, Design, System Design, Spring Boot, and coding patterns.
> Code samples target **Java 26** (records, pattern matching, sequenced collections, virtual threads, structured concurrency, scoped values, `Stream.gather`, etc.).

---

## Table of Contents
1. [Collections – Lists](#1-collections--lists)
2. [Maps](#2-maps)
3. [Sets](#3-sets)
4. [Queues & Deques](#4-queues--deques)
5. [Ordering & Searching](#5-ordering--searching)
6. [Common Coding Patterns](#6-common-coding-patterns)
7. [Specialized Maps & Sets](#7-specialized-maps--sets)
8. [Concurrent Collections](#8-concurrent-collections)
9. [MCQs](#9-mcqs)
10. [JUnit 5 Tests](#10-junit-5-tests)
11. [FAANG / Bank Real Interview Questions](#11-faang--bank-real-interview-questions)
12. [Advanced Topics](#12-advanced-topics)
13. [Data Structures & Algorithms](#13-data-structures--algorithms)
14. [Concurrency & CompletableFuture](#14-concurrency--completablefuture)
15. [JVM Internals](#15-jvm-internals)
16. [Design Patterns](#16-design-patterns)
17. [Low-Level & System Design](#17-low-level--system-design)
18. [Spring Boot, Redis, Kafka, K8s, Microservices](#18-spring-boot-redis-kafka-k8s-microservices)
19. [CodeSignal Medium / Hard](#19-codesignal-medium--hard)
20. [Mock Interview](#20-mock-interview)

---

## 1. Collections – Lists

### Q1. ArrayList vs LinkedList
| Feature | ArrayList | LinkedList |
|---|---|---|
| Backing | Resizable array | Doubly-linked nodes |
| get(i) | O(1) | O(n) |
| add at end | Amortized O(1) | O(1) |
| add/remove middle | O(n) (shift) | O(n) (traverse) + O(1) unlink |
| Memory | Compact | 2 pointers + object header per node |
| Cache locality | Excellent | Poor |
| Implements | `List`, `RandomAccess` | `List`, `Deque` |

**Rule of thumb:** default to `ArrayList`. Use `LinkedList` almost never — an `ArrayDeque` beats it for queue/deque use cases.

### Q2. Vector vs ArrayList
- `Vector` is synchronized on every method (legacy, JDK 1.0). Slow under contention, useless in single-threaded code.
- `ArrayList` is unsynchronized — wrap with `Collections.synchronizedList` or use `CopyOnWriteArrayList` / external locking when needed.
- Growth: `Vector` doubles; `ArrayList` grows by ~50%.
- Prefer `ArrayList`. For thread safety, choose the *right* concurrent structure, not `Vector`.

---

## 2. Maps

### Q3. HashMap Internals
- Backed by an array of buckets (`Node<K,V>[] table`) whose length is always a power of two.
- Index = `(n - 1) & hash` where `hash = key.hashCode() ^ (hashCode >>> 16)` (spreading).
- Load factor default `0.75`; resize doubles capacity when `size > capacity * loadFactor`.
- Collisions form a singly-linked list; **treeified** into a red-black tree when a bucket holds ≥ 8 entries *and* table length ≥ 64. Untreeified below 6.
- `null` key allowed (bucket 0). `null` values allowed.
- Iteration order is **not** guaranteed.

### Q4. LinkedHashMap
- `HashMap` + doubly-linked list across entries preserving **insertion order** (or **access order** if `accessOrder=true`).
- Predictable iteration; O(1) ops.
- Base class for a simple LRU (override `removeEldestEntry`).

### Q5. TreeMap
- Red-black tree; keys sorted by natural order or `Comparator`.
- All ops O(log n).
- Implements `NavigableMap` – `floorKey`, `ceilingKey`, `subMap`, `firstEntry`.
- No `null` keys.

### Q6. Hash Collision
Two distinct keys map to the same bucket. Handled by:
1. Chaining (linked list of nodes).
2. Treeification (RB-tree) when the chain grows and table is large enough.
Poor `hashCode()` → all keys collide → O(n) lookups → DoS risk.

### Q7. equals() vs hashCode()
Contract:
1. `a.equals(b)` ⇒ `a.hashCode() == b.hashCode()`.
2. Consistent across invocations while object unchanged.
3. `x.equals(null)` == false; equals is reflexive/symmetric/transitive.
Break the contract → duplicates in `HashSet`, lost `HashMap` entries.
In Java 26 prefer **records** which auto-generate both correctly.

```java
record Point(int x, int y) {}
```

---

## 3. Sets

### Q8. HashSet
Backed by a `HashMap` with a dummy value. O(1) add/contains/remove. No order.

### Q9. LinkedHashSet
`HashSet` + linked list of entries → insertion-order iteration. Slight memory overhead.

### Q10. TreeSet
`NavigableSet` backed by `TreeMap`. Sorted; O(log n) ops; `first`, `last`, `headSet`, `tailSet`, `subSet`.

---

## 4. Queues & Deques

### Q11. PriorityQueue
- Binary min-heap in an array.
- `offer/poll` O(log n), `peek` O(1).
- Not thread-safe (use `PriorityBlockingQueue`).
- Iteration order is **not** sorted.

### Q12. ArrayDeque
- Resizable circular array. Faster than `Stack` and `LinkedList` for stack/queue usage.
- Rejects `null`.

### Q13. Queue vs Deque
- `Queue`: FIFO, single-ended (`offer/poll/peek`).
- `Deque`: double-ended (`offerFirst/offerLast/pollFirst/pollLast`). Superset; use `ArrayDeque` as default stack.

---

## 5. Ordering & Searching

### Q14. Comparable vs Comparator
- `Comparable<T>` – natural ordering, `compareTo` implemented on the class itself.
- `Comparator<T>` – external ordering, multiple strategies, composable (`thenComparing`, `reversed`, `nullsFirst`).

```java
list.sort(Comparator.comparing(User::lastName).thenComparing(User::firstName));
```

### Q15. Collections.sort()
- Delegates to `List.sort` → `Arrays.sort` → **Timsort** (stable, adaptive, O(n log n), O(n) on nearly-sorted input).
- Primitive arrays use **Dual-Pivot Quicksort** (not stable).

### Q16. Binary Search
- `Collections.binarySearch(list, key)` requires a **sorted** list. O(log n) with `RandomAccess`, O(n) otherwise (traverses).
- Returns `-(insertionPoint) - 1` when absent.

---

## 6. Common Coding Patterns

### Q17. Reverse a HashMap
```java
Map<V, K> reversed = map.entrySet().stream()
    .collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey,
             (a, b) -> a)); // decide merge for duplicate values
```

### Q18. Merge Maps
```java
Map<String, Integer> merged = new HashMap<>(a);
b.forEach((k, v) -> merged.merge(k, v, Integer::sum));
```

### Q19. Frequency Counter
```java
Map<String, Long> freq = words.stream()
    .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
```

### Q20. Remove Duplicates (preserve order)
```java
List<T> unique = new ArrayList<>(new LinkedHashSet<>(input));
```

### Q21. Top-K Elements (by frequency)
```java
PriorityQueue<Map.Entry<String, Long>> heap =
    new PriorityQueue<>(Map.Entry.comparingByValue());
for (var e : freq.entrySet()) {
    heap.offer(e);
    if (heap.size() > k) heap.poll();
}
```
Time O(n log k), space O(k).

### Q22. LRU Cache — 3 Implementations
**(1) `LinkedHashMap` access-order**
```java
class LRU<K,V> extends LinkedHashMap<K,V> {
    private final int cap;
    LRU(int cap) { super(cap, 0.75f, true); this.cap = cap; }
    @Override protected boolean removeEldestEntry(Map.Entry<K,V> e) {
        return size() > cap;
    }
}
```
**(2) HashMap + Doubly-Linked List (interview classic)**
```java
class LRUCache {
    static class Node { int k, v; Node prev, next; Node(int k,int v){this.k=k;this.v=v;} }
    private final Map<Integer, Node> map = new HashMap<>();
    private final Node head = new Node(0,0), tail = new Node(0,0);
    private final int cap;
    LRUCache(int cap){this.cap=cap; head.next=tail; tail.prev=head;}
    public int get(int k){ Node n=map.get(k); if(n==null) return -1; move(n); return n.v;}
    public void put(int k,int v){
        Node n=map.get(k);
        if(n!=null){n.v=v; move(n); return;}
        n=new Node(k,v); map.put(k,n); addFront(n);
        if(map.size()>cap){ Node old=tail.prev; unlink(old); map.remove(old.k);}
    }
    private void addFront(Node n){n.next=head.next; n.prev=head; head.next.prev=n; head.next=n;}
    private void unlink(Node n){n.prev.next=n.next; n.next.prev=n.prev;}
    private void move(Node n){unlink(n); addFront(n);}
}
```
**(3) Thread-safe via Caffeine (production)**
```java
Cache<Integer,String> cache = Caffeine.newBuilder()
    .maximumSize(1_000).expireAfterAccess(Duration.ofMinutes(5)).build();
```

---

## 7. Specialized Maps & Sets

### Q23. WeakHashMap
Keys are held via `WeakReference`. GC can reclaim entries whose keys have no strong references. Useful for canonicalization/metadata caches. Not thread-safe.

### Q24. IdentityHashMap
Uses `==` and `System.identityHashCode` instead of `equals/hashCode`. Ideal for reference-based graphs (serializers, visitors).

### Q25. EnumMap
Backed by an array indexed by ordinal. Compact, extremely fast, iteration in enum-declaration order. Only enum keys.

### Q26. EnumSet
Bit-vector based (RegularEnumSet ≤ 64 elements, JumboEnumSet beyond). Blazing fast set ops.

---

## 8. Concurrent Collections

### Q27. CopyOnWriteArrayList
Every mutation copies the underlying array. Reads are lock-free. Best when **reads ≫ writes** (listener lists).

### Q28. ConcurrentHashMap
- Java 8+: no more segments. Uses CAS + `synchronized` at bucket-head granularity.
- `null` keys/values forbidden.
- Bulk ops: `forEach`, `search`, `reduce`, parallel variants.
- `compute`, `computeIfAbsent`, `merge` are **atomic** per key.
- Iterators are weakly consistent (no `ConcurrentModificationException`).

### Q29. BlockingQueue
Producer/consumer contract. Implementations:
- `ArrayBlockingQueue` – bounded, single lock.
- `LinkedBlockingQueue` – optionally bounded, two locks (put/take).
- `SynchronousQueue` – hand-off, zero capacity.
- `PriorityBlockingQueue` – unbounded heap.
- `DelayQueue`, `LinkedTransferQueue`.

Methods pair by failure mode: `add/remove` (throw), `offer/poll` (return), `put/take` (block), timed variants.

---

## 9. MCQs

1. Default load factor of `HashMap`? — **0.75**
2. `HashMap` treeifies a bucket when its length is at least 8 and table length ≥ ? — **64**
3. Which is thread-safe? `ArrayList`, `Vector`, `LinkedList`, `ArrayDeque`? — **Vector**
4. `TreeMap` implements? — **NavigableMap / SortedMap**
5. Which allows `null` keys? `HashMap`, `TreeMap`, `ConcurrentHashMap`, `Hashtable`? — **HashMap only**
6. Sort algorithm used by `Arrays.sort(Object[])`? — **Timsort (stable)**
7. `PriorityQueue` iteration order is sorted? — **No**
8. `HashSet.add` returns? — **boolean** (false if duplicate)
9. `LinkedHashMap` LRU flag param? — **accessOrder = true**
10. `CopyOnWriteArrayList` iterator throws `ConcurrentModificationException`? — **No**

---

## 10. JUnit 5 Tests

```java
import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.*;

class LRUCacheTest {

    @Test @DisplayName("evicts least-recently-used entry")
    void eviction() {
        LRUCache c = new LRUCache(2);
        c.put(1, 1); c.put(2, 2);
        assertEquals(1, c.get(1));
        c.put(3, 3);           // evicts key 2
        assertEquals(-1, c.get(2));
    }

    @ParameterizedTest
    @ValueSource(ints = {1, 10, 100})
    void capacity(int cap) { assertDoesNotThrow(() -> new LRUCache(cap)); }

    @RepeatedTest(5)
    void concurrentPuts() throws Exception {
        var map = new java.util.concurrent.ConcurrentHashMap<Integer,Integer>();
        try (var scope = new java.util.concurrent.StructuredTaskScope<>()) {
            for (int i = 0; i < 1000; i++) {
                int k = i;
                scope.fork(() -> map.merge(k % 10, 1, Integer::sum));
            }
            scope.join();
        }
        assertEquals(1000, map.values().stream().mapToInt(Integer::intValue).sum());
    }
}
```

---

## 11. FAANG / Bank Real Interview Questions

1. Design an LRU cache with O(1) `get`/`put`. (Google, Amazon)
2. Given a stream of integers, return top-K frequent. (Facebook)
3. Implement a thread-safe bounded blocking queue **without** using `java.util.concurrent`. (JPMorgan)
4. Explain how `ConcurrentHashMap` differs from `Collections.synchronizedMap`. (Goldman Sachs)
5. Why is `HashMap` not thread-safe? Show a failure mode. (Morgan Stanley)
6. Difference between `volatile` and `synchronized`. (Amazon)
7. Design a rate limiter (token bucket). (Stripe, Uber)
8. Reverse a singly linked list iteratively and recursively. (Meta)
9. Detect a cycle in a graph. (Google)
10. Implement `debounce` / `throttle` in Java. (Bloomberg)
11. Given `List<List<Integer>>`, merge sorted lists. (Amazon)
12. Design a URL shortener. (Google)
13. LRU with TTL and thread safety. (Netflix)
14. Explain false sharing and how `@Contended` helps. (HFT firms)
15. What happens on `HashMap` resize under concurrent writes? (Barclays)

---

## 12. Advanced Topics

### Top-K Elements — Quickselect (average O(n))
```java
int kthLargest(int[] a, int k) {
    int lo=0, hi=a.length-1, target=a.length-k;
    while (lo<=hi) {
        int p = partition(a, lo, hi);
        if (p==target) return a[p];
        if (p<target) lo=p+1; else hi=p-1;
    }
    throw new IllegalStateException();
}
```

### Immutable Collections (Java 9+)
```java
List.of(1,2,3);
Set.of("a","b");
Map.of("k",1,"k2",2);
Map.copyOf(mutable);
```
Fixed size, null-hostile, throw on mutation.

### Sequenced Collections (Java 21+, still current in 26)
`SequencedCollection`, `SequencedSet`, `SequencedMap` – `getFirst/getLast/addFirst/reversed`.

---

## 13. Data Structures & Algorithms

### Collections
See sections 1–4.

### Arrays
- `Arrays.stream`, `Arrays.copyOfRange`, `Arrays.parallelSort`.
- Rotate: reverse thrice.
- Kadane’s max subarray: O(n).

### Strings
- Immutable, interned in String Pool.
- Use `StringBuilder` for repeated concat.
- `String.chars()`, `codePoints()` for Unicode.
- Palindrome, anagram grouping (sorted key or 26-int freq key).

### HashMap & Set
See sections 2–3.

### Streams
```java
var byDept = employees.stream()
    .collect(Collectors.groupingBy(Employee::dept,
              Collectors.summingDouble(Employee::salary)));
```
Java 26 highlights: `Stream.gather(Gatherer)` for custom stateful pipelines, `mapMulti`, `toList()`.

### Recursion & Backtracking
Template:
```java
void backtrack(State s) {
    if (isGoal(s)) { record(s); return; }
    for (var choice : choices(s)) {
        apply(choice, s);
        backtrack(s);
        undo(choice, s);
    }
}
```
Classics: N-Queens, permutations, combinations, Sudoku, word search.

### Linked List
- Fast/slow pointers – cycle detection, middle node.
- Reverse in groups of K.
- Merge two sorted lists.

### Stack & Queue
- Balanced parentheses, next greater element, min-stack.
- Sliding window maximum with `ArrayDeque`.

### Trees
- BFS with queue; DFS with recursion or stack.
- LCA, diameter, serialize/deserialize.
- BST validate using bounds.

### Graphs
- BFS/DFS, topological sort (Kahn or DFS), Dijkstra (PQ), Union-Find with path compression + union by rank.
- Bellman-Ford, Floyd-Warshall for shortest paths with constraints.

### Dynamic Programming
- Identify state, transition, base.
- Memoization vs tabulation.
- Classics: LIS, LCS, knapsack, edit distance, matrix chain, coin change.

---

## 14. Concurrency & CompletableFuture

### Core
- `Runnable`, `Callable`, `Future`, `ExecutorService`.
- `synchronized`, `ReentrantLock`, `ReadWriteLock`, `StampedLock`.
- `volatile` – visibility, not atomicity.
- `Atomic*` classes, `LongAdder` under high contention.
- Happens-before, JMM.

### Java 26 Threading
- **Virtual threads** (`Thread.ofVirtual().start(...)`, `Executors.newVirtualThreadPerTaskExecutor()`).
- **Structured Concurrency** (finalized): `StructuredTaskScope` with joiners.
- **Scoped Values** replace `ThreadLocal` for immutable per-task context.

### CompletableFuture
```java
CompletableFuture.supplyAsync(this::fetchUser)
    .thenCombine(CompletableFuture.supplyAsync(this::fetchOrders), UserView::new)
    .thenApply(this::render)
    .exceptionally(ex -> fallback(ex))
    .orTimeout(2, TimeUnit.SECONDS);
```
Prefer supplying your own executor (bounded, named). Avoid the common ForkJoinPool for blocking work — or use virtual threads.

---

## 15. JVM Internals

- **Class loading:** Bootstrap → Platform → App → custom. Loading, linking (verify/prepare/resolve), initialization.
- **Memory:** Heap (Young: Eden + 2 Survivor, Old), Metaspace (class metadata, native), Stack per thread, PC, Native.
- **GC:** G1 default; ZGC / Shenandoah low-pause; Generational ZGC.
- **JIT:** C1 (fast) + C2 (optimizing) tiered. Inlining, escape analysis, scalar replacement.
- **Tools:** `jstack`, `jmap`, `jcmd`, JFR, async-profiler.
- Java 26 highlights: continued Project Leyden AOT improvements, refined Generational ZGC, tighter Foreign Function & Memory API.

---

## 16. Design Patterns

- **Creational:** Singleton (enum), Factory, Builder (records + wither), Prototype.
- **Structural:** Adapter, Decorator, Proxy (JDK dynamic proxies), Composite, Facade.
- **Behavioral:** Strategy (lambdas), Observer (Flow API), Command, Chain of Responsibility, State (sealed + pattern matching).
- Java 26 pattern-matching switch makes many polymorphic patterns cleaner:
```java
double area(Shape s) {
    return switch (s) {
        case Circle c    -> Math.PI * c.r() * c.r();
        case Square sq   -> sq.side() * sq.side();
        case Triangle t  -> 0.5 * t.base() * t.height();
    };
}
```

---

## 17. Low-Level & System Design

### LLD checklist
1. Clarify requirements & scope.
2. Identify entities → classes.
3. Define relationships & interfaces.
4. Apply SOLID.
5. Concurrency & extensibility.
6. Write clean, testable code.

Common LLD problems: Parking Lot, Elevator, Splitwise, Snake & Ladder, BookMyShow, ATM, Cache, Rate Limiter, Logger.

### HLD checklist
Requirements → Estimation → API → Data model → High-level diagram → Deep dive → Bottlenecks & scaling → Trade-offs.

Common HLD: URL shortener, Twitter feed, WhatsApp, YouTube, Uber, Instagram, Google Drive, Distributed cache, Notification system.

Building blocks: LB, CDN, cache (Redis), DB (SQL + sharding, NoSQL), Queue (Kafka), Search (Elastic), Object store (S3), Consistent hashing, CAP, quorum, replication.

---

## 18. Spring Boot, Redis, Kafka, K8s, Microservices

### Spring Boot
- Auto-configuration via `spring.factories` / `AutoConfiguration.imports`.
- Starters, Actuator, profiles, `@ConfigurationProperties`.
- Bean scopes; `@Transactional` propagation & isolation.
- Native image via Spring AOT (GraalVM).
- Testing: `@SpringBootTest`, `@WebMvcTest`, `@DataJpaTest`, Testcontainers.

### Redis
- Data types: string, hash, list, set, zset, stream, bitmap, hyperloglog.
- Persistence: RDB snapshots + AOF log.
- Pub/Sub vs Streams (consumer groups).
- Caching patterns: cache-aside, read-through, write-behind.
- Distributed locks: SET NX PX + fencing token / Redlock caveats.

### Kafka
- Topic → partitions; ordering per partition; consumer group parallelism.
- Producers: `acks=all`, idempotence, transactions (EOS).
- Offsets: auto vs manual commit.
- Retention, compaction, Schema Registry (Avro/Protobuf).
- Consumer rebalancing, cooperative sticky assignor.

### Kubernetes
- Pod, ReplicaSet, Deployment, Service, Ingress.
- ConfigMap, Secret, PVC.
- HPA/VPA, PDB, resource requests/limits.
- Liveness/readiness/startup probes.
- Rolling / blue-green / canary via Argo Rollouts.

### Microservices
- Bounded contexts; database per service; Saga (choreography/orchestration).
- API gateway, service discovery, circuit breaker (Resilience4j), retries with jitter, bulkhead.
- Observability: metrics (Prometheus), logs (ELK), traces (OpenTelemetry).
- Contract testing (Pact).

---

## 19. CodeSignal Medium / Hard

### Medium: Rotate matrix 90°
```java
void rotate(int[][] m) {
    int n = m.length;
    for (int i=0;i<n;i++) for (int j=i+1;j<n;j++) { int t=m[i][j]; m[i][j]=m[j][i]; m[j][i]=t; }
    for (int[] row: m) for (int l=0,r=n-1; l<r; l++,r--) { int t=row[l]; row[l]=row[r]; row[r]=t; }
}
```

### Medium: Longest substring w/o repeat
```java
int lengthOfLongest(String s) {
    int[] last = new int[128]; Arrays.fill(last,-1);
    int best=0, start=0;
    for (int i=0;i<s.length();i++){
        start=Math.max(start,last[s.charAt(i)]+1);
        best=Math.max(best,i-start+1);
        last[s.charAt(i)]=i;
    }
    return best;
}
```

### Hard: Word Ladder (BFS)
```java
int ladderLength(String beg, String end, List<String> words){
    Set<String> dict=new HashSet<>(words);
    if(!dict.contains(end)) return 0;
    Queue<String> q=new ArrayDeque<>(); q.offer(beg);
    int steps=1;
    while(!q.isEmpty()){
        for (int sz=q.size(); sz>0; sz--){
            char[] cur=q.poll().toCharArray();
            if (new String(cur).equals(end)) return steps;
            for (int i=0;i<cur.length;i++){
                char orig=cur[i];
                for (char c='a';c<='z';c++){
                    cur[i]=c; String n=new String(cur);
                    if (dict.remove(n)) q.offer(n);
                }
                cur[i]=orig;
            }
        }
        steps++;
    }
    return 0;
}
```

### Hard: Median of Two Sorted Arrays — O(log(min(m,n))) binary search on partitions.

### Hard: Trapping Rain Water — two pointers, O(n) / O(1).

---

## 20. Mock Interview

**Interviewer:** Design a thread-safe in-memory key/value store with TTL and LRU eviction.

**Candidate outline**
1. **Clarify:** approx entries, read/write ratio, expiration granularity, persistence?
2. **API:** `V get(K)`, `void put(K,V,Duration ttl)`, `void delete(K)`, metrics.
3. **Data structures:**
   - `ConcurrentHashMap<K, Entry<V>>` for O(1) lookup.
   - Doubly-linked list per shard for LRU order, guarded by a lock (or use `Caffeine`).
   - `DelayQueue<ExpirableKey>` or a `ScheduledExecutorService` sweep for TTL; lazy expiration on read.
4. **Concurrency:** shard by key hash to reduce contention; use `StampedLock` for LRU pointer updates.
5. **Eviction:** on `put`, if `size > cap`, evict tail node atomically.
6. **Failure modes:** hot keys, GC pressure (soft references?), thundering herd (single-flight per key with `computeIfAbsent`).
7. **Testing:** deterministic clock; JUnit 5 + concurrency stress + JMH.
8. **Scale-out path:** replace with Redis cluster; consistent hashing; write-through DB.

**Follow-ups**
- What if TTL is per-put but sweep must be O(log n)?  → min-heap keyed by expireAt or per-bucket timer wheel.
- How to avoid `computeIfAbsent` reentrancy deadlocks in CHM? → don’t call CHM ops on the same key inside the lambda.
- How would virtual threads change your design? → sweeper and per-request handlers become cheap; keep locks short.

---

### Appendix: Java 26 features referenced
- Records & record patterns
- Sealed classes + pattern matching for `switch`
- Sequenced Collections
- Virtual Threads
- Structured Concurrency (`StructuredTaskScope`)
- Scoped Values
- Stream Gatherers (`Stream.gather`)
- Foreign Function & Memory API
- Generational ZGC
- Class-file API
