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 anti pattern in cyber security?

959


what is meant by Byte code concept in Java?

1008


Explain what pure virtual function is?

972


What is string in java is it a data type?

952


What does serializing data mean?

899


What is Major and importance difference between for and foreach loop ?

1077


Differentiate between vector and array list.

996


What is the base class of all exception classes?

1021


What is final int?

951


What is final access modifier in java?

1073


What is object class in java?

870


What is Applet Stub Interface ?

2425


What is appletviewer?

987


how we can make a write-only class in java?

974


Is empty string in java?

1097