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

whats the difference between == and .equal ?

Answer Posted / manoj kumar sahu(secon pvt.ltd

In java if u use the .equal method it will compare the two
value if the values are match with each other the result
will give true otherwise false.
But if u use == it will compare the reference(address
of)two values.
s1 = new String("abc");
s2 = new String("abc");
Now, if you use the "equals()" method to check for their
equivalence as
if(s1.equals(s2))
System.out.println("s1.equals(s2) is TRUE");
else
System.out.println("s1.equals(s2) is FALSE");
it will give the output TRUE
let's try using '=='
if(s1==s2)
System.out.printlln("s1==s2 is TRUE");
else
System.out.println("s1==s2 is FALSE");
Now you will get the FALSE as output because both s1 and s2
are pointing to two different objects even though both of
them share the same string content. It is because of 'new
String()' everytime a new object is created.

if u try with out using new keyword the output will TRUE.


Is This Answer Correct ?    20 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Name four container classes.

929


Can You Have Virtual Functions In Java?

1082


I am unable to find or learn about print command. I have a graphical program in core java in applet but i want to give print command but i have coding for that so if anyone know about this plz mail me on avdhesh_chauhan007@yahoo.co.in

2037


How do you classify Dialog Box?

1065


Can a private method be declared as static?

966


Is java ee a framework?

928


What is java and its types?

1016


What is thread count in java?

951


What is thread start?

913


what is interface in java? Explain

905


What is multi-catch block in java?

1018


What about anonymous inner classes in java?

975


What happens if I remove static from main method?

969


Hi i am creating desktop application in that i want calling to mobile number. i have java telephone api (JTAPI) but i dont understand how it configure & use plese help me

1805


What is nan in java?

941