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

see, every object created by the new operator, it has it own
hash code.

so when you compare with equals(), checks only content. But
with ==, it also checks the hashcode.

try this example

package app;

public class Test {
public static void main(String[] args) {

String str2 = new String("Haneef");
String str3 = new String("Haneef");

if (str2.equals(str3))
System.out.println("ok");
else
System.out.println("Not OK");

if(str2==str3)
System.out.println("ok");
else
System.out.println("Not ok");
}
}

u get

OK
NOT OK

Is This Answer Correct ?    7 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

In Java list the methods that can be overridden?

1011


What are the differences between string and stringbuffer?

1121


What is a flag variable?

971


What are assembly attributes?

1004


What's the access scope of protected access specifier?

1038


Can I override protected method in java?

1073


Is call by reference possible in java?

962


explain the concept of virtual method invocation in polymorphism in detail?

2221


What is an empirical question?

966


What does it mean that a method or field is “static”?

975


What is the latest version of java?

1128


Is age a discrete variable?

976


Can we override a variable in java?

1013


What is package protected in java?

984


What is the need of transient variables in Java ?

1072