object equals method in java example

Publicado em: 14 Fevereiro 2017
no 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  
~-~~-~~~-~~-~


Nesta página do site você pode assistir ao vídeo on-line object equals method in java example duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Inside App 14 Fevereiro 2017, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 986 vezes e gostou 3 espectadores. Boa visualização!