Top "Equality" questions

Equality is a relationship between two or more items or variables or objects that exists if (1) the items are the same item, variable, or object or (2) the items are different items, variables or objects but they have the same value.

What's the difference between IEquatable and just overriding Object.Equals()?

I want my Food class to be able to test whenever it is equal to another instance of Food. I …

c# .net equals equality iequatable
How default .equals and .hashCode will work for my classes?

Say I have my own class public class MyObj { /* ... */ } It has some attributes and methods. It DOES NOT implement equals, …

java object equals hashcode equality
Equality comparison between multiple variables

I've a situation where I need to check whether multiple variables are having same data such as var x=1; var …

c# comparison operators equality
C# .Equals(), .ReferenceEquals() and == operator

My understanding of these three was: .Equals() tests for data equality (for the lack of a better description). .Equals() can …

c# equality
Java: How to test on array equality?

Why is the following code printing "Different."? boolean[][] a = { {false,true}, {true,false} }; boolean[][] b = { {false,true}, {true,false} }; if (…

java arrays equality
Comparing two string arrays in C#

Say we have 5 string arrays as such: string[] a = {"The","Big", "Ant"}; string[] b = {"Big","Ant","Ran"}; string[] c = {"The","…

c# .net string linq equality
Difference between String#equals and String#contentEquals methods

What is the difference between the String#equals method and the String#contentEquals method?

java string equality
How to compare Enums in TypeScript

In TypeScript, I want to compare two variables containing enum values. Here's my minimal code example: enum E { A, B } …

typescript enums compare equality
What's the difference between == and .equals in Scala?

What is the difference between == and .equals() in Scala, and when to use which? Is the implementation same as in …

scala equality scala-java-interop
JavaScript Date Comparisons Don't Equal

I've tried searching for people with similar questions, but haven't found anything. I have two dates in JavaScript, both set …

javascript date equality