Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is the difference between equals method and ==

Answer Posted / anilkumar

"==" is used to evaluate whether tht two objects are of same type or not.
Eg: A a1=new A();
A a2=new A();
A a3=a1;
a1==a2 returns false, because a1 reference and a2 reference are not same.
a3==a1 returns true because a3 reference is pointing to a1.

"equals()" compares the contents of objects.
Eg:A a1=new A(10);
A a2=new A(10);
A a4=new A(20);
a1.equals(a2) returns true because both contents are same.
a1.equals(a4) returns false because their contents are different.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When should I use singleton pattern?

1042


Can you declare an interface method static?

1068


What is an example of procedure?

1041


Why hashcode is used in java?

981


What is the difference between final, finally and finalize() in java?

1166


Explain the importance of import keyword in java?

1012


Can we create an object if a class doesn't have any constructor ( not even the default provided by constructor ) ?

1095


Explain implementation and how is it different from conversion?

1091


Explain the importance of finalize() method.

971


What is the final field modifier?

980


Can we override tostring method in java?

975


What is difference between classpath and path variables in java?

1201


What is java autoboxing?

957


What is singletonlist in java?

973


write a program that list all permutations of ABCDEF in which A appears before B?

2491