Iterator vs ListIterator vs Spliterator in Java (+ Enumeration)
Iterator vs ListIterator vs Spliterator in Java compared in one table, with Enumeration, fail-fast rules, examples and when to use each cursor.
Iterator vs ListIterator vs Spliterator in Java compared in one table, with Enumeration, fail-fast rules, examples and when to use each cursor.
Learn Java sequenced collections with examples of getFirst(), getLast(), reversed(), putFirst() and the exceptions and upgrade pitfalls to watch for.
Java ConcurrentSkipListMap keeps keys sorted for many threads. Learn skip lists, floor and ceiling keys, live range views, polling and TreeMap differences.
java.lang.UnsupportedOperationException means the code tried to change a collection that cannot be changed, such as one from Arrays.asList(), List.of() or Collections.unmodifiableMap(). Copy the data into an ArrayList or HashMap to fix it.
Java ArrayDeque tutorial with stack and queue examples, both-end methods, Java 21 reversed(), iteration, an undo history and ArrayDeque vs LinkedList.
Java SynchronousQueue explained with put(), take(), offer() and poll() examples, a producer-consumer handoff, thread pool use and the alternatives.
Java Queue interface guide with the six methods, how to choose ArrayDeque, PriorityQueue or a BlockingQueue, iteration, BFS and thread-safe queues.
Arrays.asList() vs new ArrayList() in Java explained with examples, covering fixed size, the shared array, List.of(), primitive arrays and conversions.
Learn the Java Collections Framework with a Java 21 hierarchy diagram, how to choose List, Set, Map and Queue classes, and links to every tutorial.
Create a Java nested map with computeIfAbsent and streams, add, remove and iterate entries, read values safely, deep copy, flatten and choose alternatives.
Java IdentityHashMap compares keys with == instead of equals(). Learn how it differs from HashMap, the String and Integer traps and the Java 20 change.
Java ConcurrentMap with putIfAbsent, compute and merge examples, why get-then-put loses updates, null rules and ConcurrentHashMap vs ConcurrentSkipListMap.
Java CopyOnWriteArraySet explained with examples, snapshot iteration, O(n) costs, a chat room use case and a comparison with ConcurrentHashMap.newKeySet().
Learn how Java CopyOnWriteArrayList copies its array on writes, why its iterators never fail, addIfAbsent(), Java 21 methods and when to use it.
Java TransferQueue and LinkedTransferQueue explained with transfer(), tryTransfer() and put() examples, timeouts, and a comparison with SynchronousQueue.
Java ArrayBlockingQueue examples covering put, offer, take, fairness, producer-consumer threads and batch draining with drainTo(), vs LinkedBlockingQueue.
Java PriorityBlockingQueue examples with Comparator, take(), drainTo() and a print-server worker, plus how it differs from PriorityQueue and DelayQueue.
Java priority queue tutorial with PriorityQueue examples for natural order, Comparator, max-heap, equal priorities and top K, and why it prints unsorted.
Java Spliterator examples for tryAdvance(), trySplit(), characteristics and estimateSize(), plus batching, fork/join and a custom Spliterator.
Java TreeMap keeps keys sorted in a red-black tree. Learn comparators, floorKey(), ceilingKey(), subMap(), headMap(), tailMap() views and null key rules.
Create a Java list with a single element using List.of(), Collections.singletonList(), Arrays.asList() or ArrayList. Mutability and null rules compared.
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.