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

If I will write
String s=new String("XYZ");
String s1=new String("XYZ");
if(s.equals(s1)){
sop("True");
}
else{
sop("False");
}
This program will give me "True".
But When I am creating my own class suppose
class Employee{
public Employee(String name);
}
Employee e= new Employee("XYZ");
Employee e1 = neew Employee("XYZ");
if(e.equals(e1)){
sop("True");
}
else{
sop("False");
}
Then it will give the output as "False".
Can I know what is happening internally?

Answer Posted / ashish singh

String and other wrapper classes override equals() method of object class. SO when we compare it gives the appropriate result. while the employee class did not do it.

Is This Answer Correct ?    10 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the types of arrays in java?

1036


Why are variables important in research?

912


What is set in java?

989


placement papaers of spring computing technology

1370


How can we find the actual size of an object on the heap?

1270


How many bytes is string in java?

1167


What is a dynamic array java?

896


List the three steps for creating an object for a class?

916


Is java jre still free?

911


What are the 4 types of research methods?

882


When will you define a method as static in Java?

1005


What is an interoperable application in java ?

959


What is thread pool in java with example?

958


When to use runnable interface vs thread class in java?

939


What is java util list?

889