What is the difference between equals() method and == operator.when we use 2 same strings for finding of whether both strings r equal or not by using these two,it will give same answers.i.e true and true.so what is the main defference between equals() and ==.

Showing Answers 1 - 2 of 2 Answers

Equals method is used to chekcing the two string Objects are same or not. if they are same then returns true value other wise false value.when we are using == operators strings are used as primitive data types.

  Was this answer useful?  Yes

Deepa

  • Jun 19th, 2006
 

 "==" checks with identity of variable , if they are same whereas equals checks if both variables have same values. But in case of class objects equals and == behaves the same i.e as identity equator.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions