Tuesday, 18 April 2017

What is the difference between equals() method and == operator



== operator:

  •  == operator used to compare objects references.
  • used to compare data of primitive data types
  • if  we are comparing two objects using "==" operator if reference of both are same then it will returns true otherwise returns false.
  • obj1==obj2;
  • If we are comparing primitive data type variables then it compares data of those two variables
  • Ex: int a=12; int b=12; if(a==b) returns true

No comments:

Post a Comment