Top "Equals" questions

Refers to Java equals method, indicating whether some object is "equal to" this one.

What's the best strategy for Equals and GetHashCode?

I'm working with a domain model and was thinking about the various ways that we have to implement these two …

c# .net equals gethashcode
Best practices regarding equals: to overload or not to overload?

Consider the following snippet: import java.util.*; public class EqualsOverload { public static void main(String[] args) { class Thing { final int …

java equals overloading overriding
How to compare two jsons ignoring order of elements in array properties?

I need to compare two strings which represent json objects. For testing purposes I need a way to compare these …

javascript json compare equals jsonassert
Is there a way to auto-generate GetHashCode and Equals with ReSharper?

In eclipse, when I code in Java, there is a feature to auto-generate a basic, efficient, and bug free implementation …

.net visual-studio resharper equals hashcode
Equals and Comparable with Sets

I posted some code here which correctly solved a problem the poster had. OP wanted to remove duplicates and bring …

java equals comparable compareto treeset
What is the difference between using IEqualityComparer and Equals/GethashCode Override?

When i am using dictionaries sometimes I have to change the default Equals meaning in order to compare Keys. I …

c# equals equality gethashcode iequalitycomparer
List.contains() fails while .equals() works

I have an ArrayList of Test objects, which use a string as the equivalency check. I want to be able …

java list equals contains
How to compare equality of lists of arrays with modern Java?

I have two lists of arrays. How do I easily compare equality of these with Java 8 and its features, without …

java arrays list java-8 equals
What makes reference comparison (==) work for some strings in Java?

I have following lines of codes to compare String. str1 not equal to str2, which is understandable since it compares …

java string equals
What does comparison being consistent with equals mean ? What can possibly happen if my class doesn't follow this principle?

From the JavaDoc of TreeMap : Note that the ordering maintained by a sorted map (whether or not an explicit comparator …

java comparison equals comparator comparable