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
Does hashset allow duplicates in java?
What is the flag in java?
What is method reference in java?
How many types of equations are there?
Hi.... I applied for the post of scientific officer/Engineer-SB(Programmer).Please post the syllabus and sample papers.
What is e java?
Explain about public and private access specifiers?
Explain the selection sort algorithm?
What is the difference between a local variable and an instance variable?
What should I import for arraylist in java?
What is the difference between @before and @beforeclass annotation?
Is a char always 1 byte?
State the merge-sort principle and its time complexity.
What is int argc char * argv?
Can each java object keep track of all the threads that want to exclusively access it?