@Test public void testHashcode() { Vector v1 = new Vector(1.0, 2.0); Vector v2 = new Vector(1.0, 2.0); assertEquals(v1, v2); int h1 = v1.hashCode(); int h2 = v2.hashCode(); assertEquals(h1, h2); }
@Override public int hashCode() { int result = 193; long temp = Double.doubleToLongBits(this.x); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.y); result = 37 * result + (int) (temp ^ (temp >>> 32)); return result; }
Vector implements Serializable { @Override public int hashCode() { int result = 193; long temp = Double.doubleToLongBits(this.x); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.y); result = 37 * result + (int) (temp ^ (temp >>> 32)); return result; } }
Vector implements Serializable { @Override public int hashCode() { int result = 193; long temp = Double.doubleToLongBits(this.x); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.y); result = 37 * result + (int) (temp ^ (temp >>> 32)); return result; } Vector(double x, double y); }
Vector implements Serializable { @Override public int hashCode() { int result = 193; long temp = Double.doubleToLongBits(this.x); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.y); result = 37 * result + (int) (temp ^ (temp >>> 32)); return result; } Vector(double x, double y); double getX(); double getY(); double getLength(); double getAngle(); @Override boolean equals(Object obj); @Override int hashCode(); }
Vector implements Serializable { @Override public int hashCode() { int result = 193; long temp = Double.doubleToLongBits(this.x); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.y); result = 37 * result + (int) (temp ^ (temp >>> 32)); return result; } Vector(double x, double y); double getX(); double getY(); double getLength(); double getAngle(); @Override boolean equals(Object obj); @Override int hashCode();  }