The equals() method compares two objects for equality and returns true if they are equal. The equals() method provided in the Object class uses the identity operator ( == ) to determine whether two objects are equal. For primitive data types, this gives the correct result.
=======================================================================================
// (Object.equals)
class Rect
{
int l,b;
int area()
{
return l*b;
}
Rect(int l,int b)
{
this.l=l;
this.b=b;
}
public boolean equals(Rect obj)
{
if(this.area()==obj.area())
{
return true;
}
else
{
return false;
}
}
public static void main(String []s)
{
Rect r1=new Rect(3,8);
Rect r2=new Rect(6,4);
System.out.println(r1.equals(r2));
}
}
=======================================================================================
Searches related to object class in equals methods,
hashcode method in java,
java hashcode equals,
java hashcode example,
java object equals vs ==,
what is the use of hashcode in java,
java object equals method override,
equals and hashcode contract,
object equals method in java example
www.readranks.com
www.patelwala.com
~-~~-~~~-~~-~
Please watch: "How to online money earn from Flipkart without selling any products"
• Video
~-~~-~~~-~~-~
На этой странице сайта вы можете посмотреть видео онлайн object equals method in java example длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Inside App 14 Февраль 2017, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 986 раз и оно понравилось 3 зрителям. Приятного просмотра!