Tagged articles
8 articles
Page 1 of 1
Java Architect Essentials
Java Architect Essentials
Sep 8, 2025 · Backend Development

Why Comparable Traps Your Java Sorting and How Comparator Saves the Day

This article explains the hidden pitfalls of using Java's Comparable for sorting, demonstrates how null handling and fragmented comparison logic can cause bugs, and shows how the flexible Comparator API together with chainable methods provides safer, more performant dynamic sorting solutions for constantly changing business requirements.

ComparableComparatorJava
0 likes · 7 min read
Why Comparable Traps Your Java Sorting and How Comparator Saves the Day
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Dec 28, 2023 · Fundamentals

Understanding Comparison Methods in Java

This article explains various comparison methods in Java, including equality operators, the equals() method, Comparator and Comparable interfaces, and provides code examples for primitive, object, string comparisons, as well as custom sorting logic, highlighting their roles in sorting, searching, and data handling.

ComparableComparatorComparison
0 likes · 14 min read
Understanding Comparison Methods in Java
Programmer DD
Programmer DD
Apr 6, 2022 · Backend Development

How to Remove Duplicate Strings and Objects from Java Lists Efficiently

This article explains multiple ways to eliminate duplicate strings and objects from Java List collections, covering classic Set‑based methods, Java 8 Stream distinct operations, custom equals/hashCode implementations, and field‑based deduplication using comparators and generic predicates.

ComparatorJavaList
0 likes · 6 min read
How to Remove Duplicate Strings and Objects from Java Lists Efficiently
IT Xianyu
IT Xianyu
Oct 10, 2020 · Fundamentals

How to Choose Between HashMap and TreeMap in Java

HashMap and TreeMap serve different purposes in Java: HashMap offers fast, unordered access using hash codes, while TreeMap maintains keys in sorted order via a red‑black tree, and the article explains their implementations, performance trade‑offs, and how to customize TreeMap ordering with comparators.

CollectionsComparatorData Structures
0 likes · 5 min read
How to Choose Between HashMap and TreeMap in Java
Selected Java Interview Questions
Selected Java Interview Questions
Oct 10, 2019 · Fundamentals

Choosing Between HashMap and TreeMap in Java

This article explains the differences between Java's HashMap and TreeMap, covering their underlying implementations, performance characteristics, ordering behavior, and how to use a custom comparator to achieve descending order, helping developers choose the appropriate map based on ordering and efficiency needs.

CollectionsComparatorData Structures
0 likes · 8 min read
Choosing Between HashMap and TreeMap in Java
Programmer DD
Programmer DD
Apr 19, 2019 · Fundamentals

Master Java’s Comparator: Sorting Collections, Streams, and Sets Made Easy

This article explains Java's Comparator interface, its compare method, lambda definitions, and how to use it with Collections.sort, List.sort, Arrays.sort, Stream.sorted, as well as with SortedSet and SortedMap structures, covering static and default methods like reversed, nullsFirst, thenComparing, and more.

ComparatorJavaLambda
0 likes · 31 min read
Master Java’s Comparator: Sorting Collections, Streams, and Sets Made Easy