Tag

equals

1 views collected around this technical thread.

macrozheng
macrozheng
Nov 27, 2024 · Backend Development

How a Tiny HashMap Bug Triggered a Massive Memory Leak in a High‑Traffic Microservice

A senior architect introduced a high‑concurrency monitoring feature that used a ConcurrentHashMap without proper equals/hashCode implementations, leading to duplicate keys, race conditions, and severe memory leaks, which were later resolved by correcting the key class and applying atomic map operations.

ConcurrentHashMapHashCodeJava
0 likes · 8 min read
How a Tiny HashMap Bug Triggered a Massive Memory Leak in a High‑Traffic Microservice
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.

ComparableComparatorJava
0 likes · 14 min read
Understanding Comparison Methods in Java
Cognitive Technology Team
Cognitive Technology Team
May 6, 2022 · Fundamentals

Why Java equals Returns False for Different Wrapper Types and How to Avoid It

Although numeric wrapper objects in Java may hold equal values, using the equals method on different wrapper types—or mixing primitive and wrapper types—returns false; this article explains the underlying source‑code behavior and recommends using type‑consistent equals or the compare methods to avoid bugs.

Programmingcompareequals
0 likes · 4 min read
Why Java equals Returns False for Different Wrapper Types and How to Avoid It
Selected Java Interview Questions
Selected Java Interview Questions
Sep 29, 2021 · Fundamentals

Why and How to Override hashCode() and equals() in Java

This article explains why Java developers must override both hashCode() and equals() methods for proper object comparison in hash-based collections, outlines the scenarios requiring such overrides, and provides detailed example code demonstrating correct implementations.

CollectionsHashCodeHashSet
0 likes · 7 min read
Why and How to Override hashCode() and equals() in Java
Selected Java Interview Questions
Selected Java Interview Questions
Nov 6, 2020 · Fundamentals

Understanding Java hashCode() and equals(): Design Principles and Practical Examples

This article explains the rules and design principles behind Java's hashCode() and equals() methods, illustrates their implementations in String, and provides concrete Person class examples showing how proper overriding affects Set and Map behavior.

HashCodeJavadesign principles
0 likes · 10 min read
Understanding Java hashCode() and equals(): Design Principles and Practical Examples
IT Xianyu
IT Xianyu
Oct 12, 2020 · Fundamentals

Understanding equals() and hashCode() in Java: When They Matter

This article explains the roles of equals() and hashCode() in Java, demonstrates how their interaction affects hash‑based collections like HashSet, provides multiple code examples showing correct and incorrect implementations, and outlines essential principles for overriding these methods to ensure proper object equality handling.

CollectionsHashCodeHashSet
0 likes · 9 min read
Understanding equals() and hashCode() in Java: When They Matter
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Sep 27, 2020 · Fundamentals

Understanding BigDecimal.equals: How Value and Scale Affect Equality in Java

This article explains why Java's BigDecimal.equals method compares both numeric value and scale, demonstrates common pitfalls with == and equals, shows experimental results for different constructors, and recommends using compareTo for value‑only comparisons to avoid unexpected false outcomes.

BigDecimalJavaPrecision
0 likes · 8 min read
Understanding BigDecimal.equals: How Value and Scale Affect Equality in Java
Architecture Digest
Architecture Digest
Sep 4, 2020 · Backend Development

Understanding HashMap: Why Overriding hashCode and equals Is Essential

This article explains how HashMap stores data using hash functions, illustrates hash collisions and chain addressing, and demonstrates why overriding hashCode and equals in custom key classes is essential for correct retrieval, using Java code examples and interview insights.

BackendHashCodeHashMap
0 likes · 9 min read
Understanding HashMap: Why Overriding hashCode and equals Is Essential
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Jul 16, 2020 · Backend Development

Understanding Java Integer Caching and Autoboxing: Why == Fails and How to Use equals

This article explains Java's Integer caching mechanism, why using == on Integer objects can give unexpected results outside the -128 to 127 range, how the Integer.valueOf method and the IntegerCache work, and how to inspect the behavior with javap and JVM options.

IntegerCacheJavaJavap
0 likes · 6 min read
Understanding Java Integer Caching and Autoboxing: Why == Fails and How to Use equals
Java Captain
Java Captain
Jul 11, 2020 · Backend Development

Why Overriding hashCode and equals Is Essential for Custom Keys in Java HashMap

This article explains how HashMap stores data using hash functions, illustrates the impact of hash collisions, and demonstrates with Java code why custom objects used as keys must override both hashCode and equals to work correctly in interviews and real projects.

BackendHashCodeHashMap
0 likes · 9 min read
Why Overriding hashCode and equals Is Essential for Custom Keys in Java HashMap
Sohu Tech Products
Sohu Tech Products
May 13, 2020 · Fundamentals

Deep Dive into Java HashMap: Implementation, hashCode/equals, Collision Handling, and Interview Questions

This article provides a comprehensive overview of Java's HashMap, covering its place in the Set and Map families, internal implementation details, the relationship between hashCode() and equals(), collision resolution strategies, basic operations, differences from Hashtable, and several classic interview problems such as Top‑K frequency and LRU cache design.

HashCodeHashMapInterview
0 likes · 14 min read
Deep Dive into Java HashMap: Implementation, hashCode/equals, Collision Handling, and Interview Questions
Selected Java Interview Questions
Selected Java Interview Questions
Dec 4, 2019 · Fundamentals

Understanding Java HashMap: Implementation Principles, JDK7 Source Walkthrough, and Interview Insights

This article explains the fundamentals of hash tables, dives deep into Java's HashMap implementation—including JDK7 source code analysis of its internal structures, resizing logic, and key methods—while also covering common interview questions such as why the array size must be a power of two and the necessity of overriding both equals and hashCode.

HashCodeHashMapInterview
0 likes · 19 min read
Understanding Java HashMap: Implementation Principles, JDK7 Source Walkthrough, and Interview Insights
Selected Java Interview Questions
Selected Java Interview Questions
Oct 27, 2019 · Fundamentals

Understanding the Relationship Between hashCode() and equals() in Java

This article explains how Java's hashCode() and equals() methods interact, illustrates their behavior with and without hash‑based collections through multiple code examples, and outlines the essential principles developers must follow when overriding these methods to ensure correct functionality in hash tables.

HashCodeHashMapHashSet
0 likes · 11 min read
Understanding the Relationship Between hashCode() and equals() in Java
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Oct 16, 2019 · Fundamentals

Understanding Java String Pool, intern() Method, and Comparison Techniques

This article explains how Java's String class encapsulates character arrays, the role of the string pool, the effects of the new operator, the intern() method, and the proper use of == versus equals() for reliable string comparison and memory optimization.

JavaMemory ManagementObject Comparison
0 likes · 8 min read
Understanding Java String Pool, intern() Method, and Comparison Techniques
Java Captain
Java Captain
Mar 12, 2019 · Fundamentals

Java Basics Interview Questions and Answers – Part 1

This article presents a curated set of 208 Java interview questions, focusing on the Java Basics module, and provides detailed explanations, code examples, and analyses of concepts such as JDK vs JRE, == vs equals, hashCode, final, abstract classes, and common String operations.

HashCodeInterviewJDK
0 likes · 14 min read
Java Basics Interview Questions and Answers – Part 1
Java Captain
Java Captain
Dec 28, 2017 · Fundamentals

Java Programming Essentials: Implementing equals, hashCode, compareTo, clone, and Common Idioms

This article presents a collection of essential Java programming practices, covering how to correctly implement equals, hashCode, compareTo, clone, use StringBuilder, generate random numbers, manage threads, handle I/O with try‑finally, perform defensive checks, and manipulate arrays and primitive packing.

CollectionsHashCodeJava
0 likes · 14 min read
Java Programming Essentials: Implementing equals, hashCode, compareTo, clone, and Common Idioms
Java Captain
Java Captain
Nov 11, 2017 · Fundamentals

Understanding Java's equals() and hashCode() Methods and How to Override Them

This article explains the default implementations of Java's Object.equals() and Object.hashCode(), the required contracts for overriding them, demonstrates their behavior in the String class, and provides practical guidelines and example code for correctly overriding these methods in custom classes.

HashCodeHashingJava
0 likes · 11 min read
Understanding Java's equals() and hashCode() Methods and How to Override Them