@Override public int hashCode() { int hashFirst = first != null ? first.hashCode() : 0; int hashSecond = second != null ? second.hashCode() : 0; return (hashFirst + hashSecond) * hashSecond + hashFirst; }
public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((a == null) ? 0 : a.hashCode()); result = prime * result + ((b == null) ? 0 : b.hashCode()); return result; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((fst == null) ? 0 : fst.hashCode()); result = prime * result + ((snd == null) ? 0 : snd.hashCode()); return result; }
@Override public int hashCode() { int result = hashCode; if (result == 0) { result = c != null ? c.hashCode() : 0; result = result * 37 + (d != null ? d.hashCode() : 0); hashCode = result; } return result; }
@Override public int hashCode() { int result = super.hashCode; if (result == 0) { result = unknownFields().hashCode(); result = result * 37 + (c != null ? c.hashCode() : 0); result = result * 37 + (d != null ? d.hashCode() : 0); super.hashCode = result; } return result; }
public static void main(String args[]) { System.out.println("Inheritance Main"); A a = new A(); A b = new B(); A c = new C(); // B a1 = new A(); B b1 = new B(); B c1 = new C(); // C a2 = new A(); // C b2 = new B(); C c2 = new C(); System.out.println(a.hashCode()); a.sum(); a.sub(); System.out.println(b.hashCode()); b.sum(); b.sub(); System.out.println(c.hashCode()); c.sum(); c.sub(); System.out.println(b1.hashCode()); b1.sum(); b1.sub(); System.out.println(c1.hashCode()); c1.sum(); c1.sub(); System.out.println(c2.hashCode()); c2.sum(); c2.sub(); }
@Override public int hashCode() { return 31 * (fst != null ? fst.hashCode() : 0) + (snd != null ? snd.hashCode() : 0); }
@Override public int hashCode() { return (a == null ? 0 : a.hashCode()) + (b == null ? 0 : b.hashCode()); }
public int hashCode() { if (fst == null) return (snd == null) ? 0 : snd.hashCode() + 1; else if (snd == null) return fst.hashCode() + 2; else return fst.hashCode() * 17 + snd.hashCode(); }
@Override public int hashCode() { // Hash is an exclusive-OR of both hashes. return left.hashCode() ^ right.hashCode(); }
@Override public int hashCode() { return (a.hashCode() << 7) ^ b.hashCode(); }
@Override public int hashCode() { int result = first != null ? first.hashCode() : 0; result = 31 * result + (second != null ? second.hashCode() : 0); return result; }
public int hashCode() { if (first == null) return (second == null) ? 0 : second.hashCode() + 1; else if (second == null) return first.hashCode() + 2; else return first.hashCode() * 17 + second.hashCode(); }