重写 Object.equals()方法

重写 Object.equals()方法

public boolean equals(Object obj)
{
  
if(obj ==nullreturn false;
  
else
  {
    
if(obj instanceof Cat)
    {
      cat c 
= (cat)obj;
      
if(c.color == this.color && c.height == this.height)
        {
          
return true;
        }
    }
  }
  
return false;
}
原文地址:https://www.cnblogs.com/sevenyuan/p/1608593.html