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

Give few difference between constructor and method?

514


What is an iterator interface in java programming?

530


Explain the features of interfaces in java?

554


What is the use of StringTokenizer class?

607


Explain differences between collection api and stream api?

610






Will minecraft java be discontinued?

644


Why can't we make a class private in java?

534


What are the topics in core java?

529


What are the steps involved to write rmi based programs?

561


Which is better 64 bit or 32 bit?

505


What is the major advantage of external iteration over internal iteration?

613


What is the use of conditional statement?

562


Which list is sorted in java?

580


Why does the integer quotient -0/3 yield 0, but the double quotient -0.0/3.0 yields – 0.0?

603


Is vector synchronized in java?

548