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 / k.packiya lakshmi
In String we can write a string in double quotes and equals is
one method of string but when we creating class it doesn't
know the method of equals.
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
What is ascii code?
What is difference between synchronize and concurrent collection in java?
What are locale settings?
What does main method?
What is an object’s lock and which object’s have locks?
How to sort a collection of custom Objects in Java?
What is sorting in java?
What is the difference between Error, defect,fault, failure and mistake?
Explain thread in java?
What are the 7 types of characters?
Under what conditions is an object’s finalize() method invoked by the garbage collector?
What is object class in java?
What are jee technologies?
Can java run on google chrome?
What is autoboxing in java?