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
What is boolean example?
What is Mutex (Mutual Exclusion Object) ?
What kind of variables can a class consist?
In a container there are 5 components. I want to display the all the components names, how will you do that one?
How garbage collection is done in java?
What is Java Package and which package is imported by default?
Define how destructors are defined in java?
What is anonymous inner class?
What are data types in oop?
What are access specifiers available in java?
What is a singleton puppy?
What are the four pillars of java?
Explain access specifiers?
Is string a datatype?
What modifiers may be used with an inner class that is a member of an outer class in java programming?