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
Is a char always 1 byte?
What is stringwriter?
What is return code?
How to sort an array in java without using sort method?
Explain what is encapsulation?
How many types of voids are there?
What is the use of a conditional inclusion statement in Java ?
What are green threads in java?
What is final?
What is the biggest integer?
What is an empty list in java?
How does arraylist size increase in java?
What is the difference between jvm and jre? What is an interface?
What is the java virtual machine?
If an application has multiple classes in it, is it okay to have a main method in more than one class?