Java Spliterator: trySplit(), Characteristics and Examples
Java Spliterator examples for tryAdvance(), trySplit(), characteristics and estimateSize(), plus batching, fork/join and a custom Spliterator.
“Core Java” is Sun’s term, used to refer to Java SE, the standard edition and a set of related technologies, like the Java VM, CORBA, etc. This is mostly to differentiate from others like Java ME or Java EE. “Core Java” is Oracle’s definition and refers to subset of Java SE technologies.
The Core Java technologies and application programming interfaces (APIs) are the foundation of the Java Platform, Standard Edition (Java SE). They are used in all classes of Java programming, from desktop applications to Java EE applications.
Java Spliterator examples for tryAdvance(), trySplit(), characteristics and estimateSize(), plus batching, fork/join and a custom Spliterator.
Java ListIterator examples for forward and backward traversal, listIterator(index), cursor positions and the rules for add(), set() and remove().
Java Iterator explained with hasNext(), next(), remove() and forEachRemaining(), how modCount causes ConcurrentModificationException, and Enumeration.
Java Comparator interface with lambdas, comparing(), thenComparing(), reversed() and nullsFirst(), plus sorting by multiple fields in Java 25.
Learn the Java Comparable interface with compareTo() examples, the contract rules, the subtraction and equals() traps, and natural order in records.
Learn the Java LinkedList class with examples. List and Deque methods, an undo stack, Java 21 reversed(), real time complexity and when to use it.
Learn Java TreeSet with examples. Sorting with comparators, floor() and ceiling(), range views, the compareTo() duplicate trap and Java 21 methods.
Learn Java LinkedHashSet with examples. Keep insertion order, remove duplicates, and use Java 21 getFirst(), addFirst() and reversed() on a SequencedSet.
Learn Java HashSet with examples. How it detects duplicates, equals() and hashCode(), set operations, newHashSet(), performance and HashSet vs TreeSet.
Java Hashtable is a synchronized legacy map. See how it works, why compound updates still race, HashMap vs Hashtable, and when to use ConcurrentHashMap.
Java TreeMap keeps keys sorted in a red-black tree. Learn comparators, floorKey(), ceilingKey(), subMap(), headMap(), tailMap() views and null key rules.
Java LinkedHashMap keeps keys in insertion or access order. See SequencedMap methods from Java 21 and build an LRU cache with removeEldestEntry().
Learn to deep copy a HashMap in Java with copy constructors, streams and serialization, and compare shallow copies with new HashMap, clone() and copyOf().
Learn to remove duplicates from ArrayList in Java with distinct(), LinkedHashSet and removeIf(), plus duplicate objects by a field and ignoring case.
Learn to find, count and remove duplicates from an array in Java with HashSet, frequency maps, distinct() and an in-place loop for sorted arrays.
Compare ConcurrentHashMap vs synchronizedMap in Java by locking, iteration, null handling and atomic updates, and pick the right map for shared data.
Merge two maps in Java with putAll(), putIfAbsent(), merge() or Collectors.toMap(), and control duplicate keys, sums, list values and unchanged inputs.
Compare two maps in Java with equals(), keySet() and value counts, list added, removed and changed entries, and build a full diff with Guava.
ArrayList removeIf() removes every element that matches a Predicate. See return values, exceptions, Map views, lists that refuse it and stream filters.
ArrayList forEach() runs a Consumer on each element. Learn method references, andThen(), break and index workarounds, CME rules and Map.forEach().
Java ArrayList clone() creates a shallow copy. Learn how it differs from a deep copy and how to deep copy a list with copy constructors and streams.
Learn what a Java tuple is, why records replace it since Java 16, and how to create, read and change javatuples Pair, Triplet and Quartet objects.
LinkedList vs ArrayList in Java compared on memory, time complexity and real use cases, plus ArrayDeque advice and how to convert between them.
ArrayList vs Vector in Java compared on synchronization, capacity growth and iteration, with modern replacements for Vector, Stack and Enumeration.
Learn to convert Set to List in Java with the ArrayList constructor, List.copyOf() and streams, keep or sort the order, and convert a List to a Set.
Convert array to ArrayList in Java with new ArrayList<>(Arrays.asList()), List.of() or streams. Covers fixed-size views, int[] arrays and the way back.
Learn how to check if element exists in ArrayList in Java with contains(), indexOf(), lastIndexOf() and anyMatch(), incl. custom objects and fast lookups.
Learn to replace element in ArrayList in Java by index or value with set(), indexOf(), Collections.replaceAll() and List.replaceAll(), with safe examples.
Check if ArrayList is empty in Java with isEmpty() or size(), handle null lists with Commons and Spring, and empty a list with clear() vs removeAll().
Java format phone number examples with regex groups and replaceFirst(), cleanup of typed input, a safe method with Optional, substring and E.164 storage.
Get first 4 characters of a string in Java with substring() and Math.min(), safe for short strings, null and emoji, plus previews with an ellipsis.
Get last 4 characters of a string in Java with substring() and Math.max(), handling short strings, null, emoji and formatted phone numbers.
Merge two ArrayLists in Java with addAll() or Stream.concat(), drop duplicates with LinkedHashSet, merge sorted lists and merge objects by key.
Serialize an ArrayList to a file or a byte array with ObjectOutputStream, read it back with ObjectInputStream, handle the unchecked cast, and see when JSON with Jackson is the better choice.
Swap two elements in ArrayList with Collections.swap(), by value or with set(), avoid IndexOutOfBoundsException and move items with rotate().
Create a synchronized ArrayList with Collections.synchronizedList() or CopyOnWriteArrayList, lock iteration correctly and pick the right option.
Compare two lists in Java with equals() or ignoring order, count duplicates correctly, and find additional, missing and common items with removeAll().
Learn how to add multiple elements to ArrayList in Java with addAll(), Collections.addAll(), add(index), addFirst() and streams, plus common exceptions.
Learn to remove element from ArrayList in Java by index, value or condition with remove(), removeIf(), removeAll() and retainAll(), plus common traps.
Learn to iterate ArrayList in Java with the for-each loop, index loop, forEach(), Iterator, reversed() and streams, and remove elements without errors.
Java String split() explained with the limit argument, escaping regex special characters, trailing empty strings and Java 21 splitWithDelimiters().
Java String startsWith() examples for single and multiple prefixes, the offset overload, ignoring case with regionMatches, regex prefixes and null safety.
Find duplicate characters in a string in Java with a map, streams, an int array or sorting, plus case, emoji, first unique character and complexity.
Learn how Java hashCode and equals work, the contract between them, why HashSet breaks when only equals() is overridden, plus records and mutable keys.
Convert float to String in Java with Float.toString(), String.format(“%.2f”) and DecimalFormat, plus locale, rounding, null and scientific notation.
Convert an exception stack trace to string in Java with StringWriter and PrintWriter, read causes and suppressed lines, and store or log it safely.
Fix InvalidKeyException Parameters missing by passing the IV to Cipher.init(), with AES-GCM IV storage and InvalidAlgorithmParameterException causes.
Java AES encryption and decryption with AES-256-GCM, random IVs, key storage, PBKDF2 and HKDF keys, file encryption, tamper detection and common mistakes.
Right pad a string in Java with spaces, zeros or any character using String.format(), repeat(), StringUtils.rightPad() and Guava, plus truncation.
Left pad a string in Java with spaces or leading zeros using String.format(), repeat(), StringUtils.leftPad() and Guava, with negative numbers and nulls.
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.