object equals method in java example

Publicado el: 14 febrero 2017
en el canal de: Inside App
986
3

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  
~-~~-~~~-~~-~


En esta página del sitio puede ver el video en línea object equals method in java example de Duración hora minuto segunda en buena calidad , que subió el usuario Inside App 14 febrero 2017, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 986 veces y le gustó 3 a los espectadores. Disfruta viendo!