Tagged articles
equals
37 articles · Page 1 of 1
The article explains what Lombok’s @Data annotation expands to, warns that its default @EqualsAndHashCode callSuper is false causing equals/hashCode to ignore superclass fields, discusses the need to manually declare serialVersionUID for Serializable classes, and recommends using @Getter/@Setter with explicit @EqualsAndHashCode when inheritance is involved.
JavaLombokdata
0 likes · 5 min read

The article explains Java's Object class as the root of all classes, details its fundamental methods such as clone, equals, hashCode, toString, finalize and getClass, illustrates shallow vs. deep copying, shows how to override equals with a Book example, and warns about using finalize for cleanup.
CloneFinalizeJava
0 likes · 10 min read

The article explains the contract between equals and hashCode in Java, shows what goes wrong when only one is overridden, demonstrates the correct implementation with Objects.equals and Objects.hash, covers IDE/Lombok generation, JPA entity nuances, inheritance pitfalls, records, and common anti‑patterns.
Best PracticesHashMapJPA
0 likes · 9 min read

This article explains how == compares primitive values and object references, why Object.equals() defaults to ==, how classes like String and Integer override equals(), the impact of the string constant pool, integer caching, auto‑boxing, floating‑point pitfalls, and best practices for correctly comparing objects in Java.
InterviewJavaReference Types
0 likes · 16 min read

The article explains why a HashMap lookup can return null even when key objects have identical fields, showing that the default equals and hashCode implementations compare memory addresses, and demonstrates how overriding both methods fixes the issue and avoids real‑world bugs.
CachingHashMapJava
0 likes · 8 min read

This article breaks down Java's Object class, detailing its twelve core methods—including equals, hashCode, clone, getClass, notify, notifyAll, and the various wait overloads—providing clear explanations, usage examples, and best‑practice guidelines for developers.
CloneFinalizeJava
0 likes · 4 min read

This article explains the purpose and contract of Java's equals and hashCode methods, shows how the default implementations work, demonstrates why String overrides equals, outlines the three-step equality check, and provides guidelines for correctly overriding these methods in custom classes.
JavaObjectcollections
0 likes · 7 min read


ITPUBDec 22, 2024 · Fundamentals
This article explains why using the == operator on two Integer objects in Java can yield true for some values and false for others, covering Integer caching, the role of Integer.valueOf, and the correct way to compare Integer values with equals.
IntegerJavaObject Comparison
0 likes · 7 min read

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.
ConcurrentHashMapJavaMemoryLeak
0 likes · 8 min read

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

This article highlights six frequent Java pitfalls—including misuse of == with Integer, Objects.equals quirks, BigDecimal precision loss, Stream filter side‑effects, auto‑unboxing null errors, and String replace nuances—providing code examples and best‑practice recommendations to help developers write safer, more reliable code.
Auto-unboxingJavaString
0 likes · 12 min read

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.
ObjectsWrappercompare
0 likes · 4 min read

This article explains why the java.math.BigDecimal(double) constructor can cause precision loss, recommends using the String constructor for monetary values, and advises comparing BigDecimal instances with compareTo instead of equals to avoid scale‑related mismatches.
Best PracticesJavabigdecimal
0 likes · 4 min read

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.
HashSetJavaObject
0 likes · 7 min read

This article explains the purpose of Java's hashCode() and equals() methods, outlines the rules for overriding them, demonstrates common pitfalls with HashSet through a concrete code example, and clarifies why both methods must be overridden when using custom objects as HashMap keys.
HashMapHashSetJava
0 likes · 6 min read

This article explains the relationship between Java's equals and hashCode methods, outlines their contractual requirements, shows how the default implementations work, demonstrates proper overrides with code examples, and provides practical guidelines for implementing robust hashCode functions to ensure correct behavior in hash‑based collections.
HashMapJavaObject
0 likes · 11 min read

This article explains Java's autoboxing and unboxing processes, illustrates how wrapper classes like Integer, Double, and Boolean handle value conversion and caching, shows the generated bytecode, discusses performance impacts of object creation, and warns about comparison and null‑pointer pitfalls.
AutoboxingJavaNullPointerException
0 likes · 9 min read

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.
Design PrinciplesJavaequals
0 likes · 10 min read

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.
HashSetJavaObject Equality
0 likes · 9 min read

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.
JavabigdecimalcompareTo
0 likes · 8 min read

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.
BackendHashMapInterview
0 likes · 9 min read

This article explains the JVM storage mechanisms for primitive and wrapper types, the Integer cache range, autoboxing/unboxing behavior, and why certain Integer comparisons using ‘==’ return true or false, providing code examples and detailed analysis.
AutoboxingIntegerJVM
0 likes · 12 min read

This article explains how Java’s == operator compares object references while the String class’s equals method compares actual character values, covering JVM memory layout, literal pooling, code implementation, and practical examples that clarify common interview questions.
InterviewJVMJava
0 likes · 8 min read

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.
AutoboxingIntegerCacheJava
0 likes · 6 min read

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.
InterviewequalshashCode
0 likes · 9 min read

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.
CollisionHashMapInterview
0 likes · 14 min read

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.
HashMapInterviewJDK7
0 likes · 19 min read

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.
HashSetequals
0 likes · 11 min read

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.
InternObject ComparisonString
0 likes · 8 min read

This article explains the contract between hashCode() and equals() in Java, shows the problems caused by violating it—such as incorrect behavior in HashMap/HashSet and memory leaks—and provides practical guidelines and code examples for implementing robust hashCode methods, including the use of Apache's HashCodeBuilder.
HashMapHashSetImmutable Objects
0 likes · 15 min read

This article explains the contract of equals and hashCode in Java, shows what goes wrong when only equals is overridden, provides a vivid house‑ownership analogy, and offers practical guidelines and code examples for correctly overriding both methods.
JavaObjectbackend development
0 likes · 5 min read

The article explains how HashMap stores data using hash functions, illustrates hash collisions and chain addressing, and demonstrates through Java code why overriding both hashCode and equals in custom key classes is essential for correct retrieval from a HashMap.
HashMapInterviewJava
0 likes · 10 min read

This article explains the purpose, differences, and proper usage of Java's hashCode() and equals() methods, offering clear interview guidance, performance considerations, and when to override them for reliable behavior in hash‑based collections.
BackendJavaObject Comparison
0 likes · 8 min read

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.
Best PracticesClonecollections
0 likes · 14 min read

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.
@OverrideObjectString
0 likes · 11 min read

This article presents four practical Java optimization strategies—targeted performance tuning, replacing primitive constants with enums, correctly overriding the equals() method, and increasing the use of polymorphism—to improve system efficiency and code readability while highlighting when each technique should be applied.
Javaenumsequals
0 likes · 18 min read

This article explains how Java's default equals() compares object references, why overriding both equals() and hashCode() is required for correct behavior in collections like HashMap, and demonstrates the proper implementations with code examples and a detailed look at HashMap's internal mechanics.
HashMapJavaequals
0 likes · 11 min read
