EQUAL AND HASHCORD METHOD

Equals method is part of Object class.
It will check for the equality .
It will if both the object are referring to the same address, if yes it will return .
In String class equals method is overridden, if the content of the both the string are same it will return true.
In Integer class equals method will be numerical comparison.
When we are overriding the equal method:
public boolean equals(Object obj), this is overriding
public boolean equals( Person obj), person is our class..This is Overloading not overriding.
So Better to use @override annotation, so that at compile time only we can check that.
 
Equals and Hashcode Method:
Contrast between Hashcode and equals method in java
- If two list are equal
- If two objects are not equal ,then their hashcode can be same or different.
- Approach to Override equals method in java
This check-if true then return true
null check-if true then return false.
instanceof check-if false return false.
compare each attribute.