object equals method in java example

Pubblicato il: 14 febbraio 2017
sul canale di: 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  
~-~~-~~~-~~-~


In questa pagina del sito puoi guardare il video online object equals method in java example della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Inside App 14 febbraio 2017, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 986 volte e gli è piaciuto 3 spettatori. Buona visione!