what is the difference between equals method and ==
Answer Posted / chanchal verma
== compares the reference values whether they are pointing to the same object or not. equals() method compares the contents of two objects.
Ex.
String s1=new String("chanchal");
String s2=new String("chanchal");
System.out.println(s1==s2);// prints false
System.out.println(s1.equals(s2));
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
When does a class need a virtual destructor?
What is n in java?
Why local variables are stored in stack?
What does t in java mean?
What are the advantages of user defined functions?
What are the access modifiers available in java?
How do you remove duplicates in java?
What’s the difference between constructors and other methods?
What is difference between final and finally in java?
What is the declaration statement?
What is hasnext in java?
What are the differences between string and stringbuffer?
Why do we need singleton class?
A person says that he compiled a java class successfully without even having a main method in it? Is it possible?
What is an array length?