Browse by Topic
Popular
Popular Posts
Latest
Latest Java Posts
Java HashSet equals and hashCode Explained
Learn how Java HashSet uses equals() and hashCode() for duplicate detection, how to implement the contract correctly, and common mistakes to avoid.
Java HashSet vs TreeSet: Choosing the Right Set
Compare Java's HashSet and TreeSet by ordering, performance, null handling, and use cases to choose the right Set implementation.
Java HashSet vs LinkedHashSet: Ordering and Tradeoffs
Compare HashSet and LinkedHashSet in Java: ordering guarantees, internal structure, memory costs, iteration behavior, and when to choose each implementation.
Java HashSet Order: Unpredictable by Design
Learn why HashSet iteration order is not guaranteed and how LinkedHashSet, TreeSet, or sorting can give you predictable ordering.
Java HashSet and null: Behavior and Pitfalls
How Java's HashSet handles null elements, including storage, performance, and common pitfalls when using null in set operations.
Java HashSet: Remove Duplicates from a List
Learn how to remove duplicates from a Java List with HashSet, including the equals and hashCode contract, ordering with LinkedHashSet, and edge cases such as nulls and mutable objects.
Java HashSet Duplicates: Behavior and Detection
Java HashSet silently ignores duplicate elements. This article explains how equals() and hashCode() control duplicate detection and how to use add()'s return value to catch duplicates.
Java HashSet Iteration: Order, Removal, and Performance
Iterate a Java HashSet safely, understand why iteration order is not guaranteed, and remove elements without triggering ConcurrentModificationException.
Java HashSet Size: Using size() Correctly
Learn how to get the number of elements in a Java HashSet with size(), its constant-time behavior, and common pitfalls to avoid.
Java HashSet contains: Usage and Behavior
java hashset contains: Learn how HashSet.contains works in Java, its average O(1) lookup, null handling, and the equals/hashCode contract that makes it reliable.