1.

Difference between equality and identity in maths

Answer»

identity: a variable holds the same instance as ANOTHER variable.

equality: two distinct OBJECTS can be used INTERCHANGEABLY. They often have the same id.

E.g:

   Integer a = new Integer(100);

   Integer b = a;

a is identical to b.

   Integer C =  new Integer(100);

   Integer d = new Integer(100);

c is equal but not identical to d.

Of course, two identical variables are always equal.



Discussion

No Comment Found

Related InterviewSolutions