what is equals() method in java?

   public boolean equals(Object o): 
          

  • This equlas() method is used to check the equality of two objects.
  • This method applicble for object references but not for primitives.
  • we can Override .equals() method for content comparison.
  • for any Object reference r ,r.equals(null) is lways false.
   Example:

No comments:

Post a Comment