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


Please Help Members By Posting Answers For Below Questions

How do you add an element to an arraylist in java?

492


explain the concept of virtual method invocation in polymorphism in detail?

1723


Explain java coding standards for constants?

581


What are inbuilt functions?

573


Explain try and catch keywords in java?

625






What is xslt in java?

529


What are the ways in which a thread can enter the waiting state?

520


What are the different types of garbage collectors in java?

552


what is session in java?

758


Can a method inside a interface be declared as final?

534


What is difference between path and classpath variables?

566


What are the differences between abstract class and interface?

515


What is the association?

557


What are the differences between string, stringbuffer and stringbuilder?

531


Why is it called a string?

569