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

Answers were Sorted based on User's Feedback



what is the difference between equals method and ==..

Answer / 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

what is the difference between equals method and ==..

Answer / r ramya

== checks the string value
equals for checking the strinhg object
String s1="hai";
String s2=new String("hai");
sop(s1==s2);//false
sop(s1.equals(s2));//true

Is This Answer Correct ?    0 Yes 0 No

what is the difference between equals method and ==..

Answer / chanchal verma

== compares the reference values whether they are pointing to the same object or not. equals() method compares the contents of two objects.
Ex.
String s1=new String("chanchal");
String s2=new String("chanchal");
System.out.println(s1==s2);// prints false
System.out.println(s1.equals(s2));

Is This Answer Correct ?    0 Yes 0 No

what is the difference between equals method and ==..

Answer / ramanareddy333

equal method compare the the content of the strings,where
as == compares the referance variables .
for example
string s1 = 'ramana'
string s2= ' ramana'
if(s1==s2)
s.o.p("s1, s2 are same");
else
s.o.p(" s1, s2 are not same");

ans = s1,s2 are not same because == compares the referance
variables.

Is This Answer Correct ?    6 Yes 8 No

what is the difference between equals method and ==..

Answer / upendar

== checks wheather two strings are pointing to same location
or not.

equals method checks wheather the strings are same or not

Is This Answer Correct ?    2 Yes 4 No

what is the difference between equals method and ==..

Answer / leo zhao

Hi Ravi,
a==c----> returns true, only if obj1 c = a.

Is This Answer Correct ?    3 Yes 6 No

what is the difference between equals method and ==..

Answer / thevendhiran.k

equal method is used to check whether the two strings are
equal(same). exmpl: if the 1st string is 'deva' then it ll
check the 2nd is also 'deva'. whereas = is a assignment
operator used to assign a value to the variable.

Is This Answer Correct ?    13 Yes 54 No

Post New Answer

More Core Java Interview Questions

How many types of constructors are used in java?

0 Answers  


basic difference b/w ALL types of JDBC driver.

1 Answers   Systematix,


what is difference between String buffer and String builder?

5 Answers   Benchmark,


What is string length in java?

0 Answers  


If an object is garbage collected, can it become reachable again?

0 Answers  


how an we achive multiple inhetitance in java using interface..??

2 Answers  


GoldMansachs Interview process....

1 Answers   Goldman Sachs,


Is it compulsory to have atleast one abstract method in abstract class?

10 Answers  


What is the synonym of procedure?

0 Answers  


why the wait,notify,notifyall methods are placed in object class?these are the thread concepts why these methods are placed in Object class?

2 Answers   Global Logic, Satyam,


How use .contains in java?

0 Answers  


What is keyset in java?

0 Answers  


Categories