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

What is bom encoding?

949


Can we instantiate interface in java?

1089


Is main a function?

961


Is class is a data type?

1019


what is ststic with example

2002


Which command from the jdk compiles a java program?

916


What is an abstract class and what is it’s purpose?

907


What is a qualifier in a sentence?

926


What is java Applet?

1034


Is alive method in java?

917


Explain about interrupt() method of thread class ?

1063


What is abstraction in java?

1024


What is JDBC Driver interface?How can you retrieve data from the ResultSet

2046


What is type inference in java8?

977


What is rmi and steps involved in developing an rmi object?

992