what is the difference between equals method and ==

Answer Posted / y.v.v.d.ravikanth

equals() method is from Object Class.So this is the method
to check the equality between two objects.This method
implements the equalence relation.

ex obj1 o1 = "ravi";
obj2 o2 = "ravi";

o1.equals(o2) ;// returns true.

== Operator. no doubt this is the operator. It can be used
in two ways
1:To compare the values of primitive variables.
2.To compare the object refference variables.
it returns true if refference variable reffering to the
same object.

ex obj1 a
obj2 b
obj1 c

a==c----> returns true.
a==b----> returns false.

Is This Answer Correct ?    17 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What string is utf8?

549


Write a program to calculate factorial in java?

587


Is logger a singleton?

528


What is an example of a constant variable?

539


What is compareto?

546






Difference between method overloading and method overriding in java ?

578


What is difference between null and void?

535


What is api in java?

543


What is java util?

541


What is method reference?

521


What are the library functions in java?

552


What is the SimpleTimeZone class?

1801


How do you access command-line arguments within the code?

573


What is hash table in java?

494


What is the difference between a field variable and a local variable?

577