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

What is the difference between Array and Hash Table?

1027


How to create com object in Java?

1073


What is a java string?

1074


what is the use of bean managed and container managed with example?

1971


What is parsing and its types?

1099


What are different types of states exist for a thread?

1008


Implement two stacks using a single array.

1059


What is the difference between jvm and jre? What is an interface?

1093


What are the different tags provided in jstl?

954


How do you implement tree mirroring in java?

1074


What are inbuilt functions?

981


Why are generics used?

960


What is the purpose of the main method?

990


How can we create a synchronized collection from given collection?

1082


What is a superclass?

1344