Browse by Topic
Popular
Popular Posts
Latest
Latest Java Posts
Java HashMap Initialization: Syntax and Pitfalls
Learn how to initialize a HashMap in Java, including constructors, capacity and load factor, copy constructors, Map.of, and common pitfalls.
Java HashMap Declaration: Syntax and Common Pitfalls
Learn correct HashMap declaration syntax in Java: generics, the diamond operator, initial capacity, and when to choose immutable Map.of instead.
Java HashMap: How It Works and When to Use It
Understand Java HashMap's internal structure, performance characteristics, and common pitfalls to write efficient, predictable code.
Java Set vs List: Choosing the Right Collection
Compare Java's Set and List interfaces: ordering, duplicates, access patterns, implementation tradeoffs, and when each collection fits your code.
Creating and Using Java Immutable Sets
Learn how to create and use Java immutable sets with Set.of, understand their null and ordering behavior, and avoid common pitfalls with unmodifiable views.
Java Set.of(): Creating and Using Sets
Learn how to create, populate, and iterate over a Set in Java, including the differences between HashSet, TreeSet, and LinkedHashSet.
Java Set Methods: Usage and Behavior
Learn how Java Set methods work, including add, remove, contains, and iteration, with practical examples for HashSet, LinkedHashSet, and TreeSet.
Java Set Interface: Implementation Choices and Behavior
Understand the Java Set interface contract and how HashSet, LinkedHashSet, TreeSet, and EnumSet differ in ordering, null handling, and concurrency behavior.
Java TreeSet Null Handling: Allow or Reject Nulls
A TreeSet throws NullPointerException when adding null without a comparator that handles it. This article explains why, and how to allow nulls with Comparator.nullsFirst or nullsLast.
Java TreeSet ceiling and floor methods
java treeset ceiling floor: Learn how to use TreeSet's ceiling and floor methods to find nearest elements, handle edge cases, and understand their performance.