Object - superclass для всех классов в JAVA, кроме примитивов. Необходим для предоставления основных методов в каждый java класс.
class Color{
public Color(){ /* ... */ } // default constructor
public Color(Color c){
this.name = c.name; // copy all attributes
}
// other methods
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj == null || obj.getClass() != this.getClass()) {
return false;
}
Person guest = (Person) obj;
return a == guest.a && b.equals(guest.b) && c.equals(guest.c) //Если ссылочная переменная то equals()
}
public int hashCode() {
return Objects.hash(a, b, c);
}