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
How do you add an element to an arraylist in java?
explain the concept of virtual method invocation in polymorphism in detail?
Explain java coding standards for constants?
What are inbuilt functions?
Explain try and catch keywords in java?
What is xslt in java?
What are the ways in which a thread can enter the waiting state?
What are the different types of garbage collectors in java?
what is session in java?
Can a method inside a interface be declared as final?
What is difference between path and classpath variables?
What are the differences between abstract class and interface?
What is the association?
What are the differences between string, stringbuffer and stringbuilder?
Why is it called a string?