DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Compact Equals Method
class Foo {
private String string;
private int i;
[...]
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Foo)) return false;
final Foo other = (Foo) o;
if (string != null ? !string.equals(other.name) : other.name != null) return false;
if (i != other.i) return false;
[...]
return true;
}






Comments
Snippets Manager replied on Wed, 2007/02/14 - 2:44pm