![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Objekt-orienteret programmering i Java, del 1 - slide 26 : 27 |
|
class EqualsDemo { private int state; public EqualsDemo (int state){ this.state = state; } public boolean equals(Object other){ int thisState = this.state; int otherState = ((EqualsDemo) other).state; if (other instanceof EqualsDemo) return thisState == otherState; else return false; } } |