Skip to content

Instantly share code, notes, and snippets.

@nullren
Created November 20, 2015 00:51
Show Gist options
  • Save nullren/7ff41496090e7e920e23 to your computer and use it in GitHub Desktop.
Save nullren/7ff41496090e7e920e23 to your computer and use it in GitHub Desktop.
// Lazily initialized, cached hashCode
private volatile int hashCode = 0; // (See Item 48)
public int hashCode() {
if (hashCode == 0) {
int result = 17;
result = 37*result + areaCode;
result = 37*result + exchange;
result = 37*result + extension;
hashCode = result;
}
return hashCode;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment