If you want to set the uniqueness of a class, you need to override the hashCode) metho... and the equals(Object o) method. The way Java works, it uses the hashcode value to determine whether or not you have the same object... If Java senses the same two instances of objects are equal, it'll execute the equals method In the example below, I'm setting the hashcode for a Rectangle using the Objects.hash0 method, using iWidth and iLength as parameters. I'm telling Java that two Rectangles with the same Width and Length are the SAME rectangle. Question How would you code the hashcode) method in Deck if you wanted to consider each card unique? The correct code wouldn't allow the Ace of Spades to be added twice to the same HashSet if there's only one deck of cards. * hashCode - I'm overriding the hashCode method n object- setting the hashCode to the width&Length of the rectangle. What I'm trying to do is * make rectangles unique by width & length override public int hashCode) ( return objects.hash(iwidth, Length) * equals. This method is triggered when two objects with the same hashCode are detected. Even though I'n setting hashcode myself, I have to also override the equals method to tell java when one objectsanother. 0verride public boolean equals(object o) if (o-this) return true; if ((o instanceof Rectangle)) return false; Rectangle rec(Rectangle) o; return objects.equals (hashCode(), rec.hashCode(O) If you want to set the uniqueness of a class, you need to override the hashCode) metho... and the equals(Object o) method. The way Java works, it uses the hashcode value to determine whether or not you have the same object... If Java senses the same two instances of objects are equal, it'll execute the equals method In the example below, I'm setting the hashcode for a Rectangle using the Objects.hash0 method, using iWidth and iLength as parameters. I'm telling Java that two Rectangles with the same Width and Length are the SAME rectangle. Question How would you code the hashcode) method in Deck if you wanted to consider each card unique? The correct code wouldn't allow the Ace of Spades to be added twice to the same HashSet if there's only one deck of cards. * hashCode - I'm overriding the hashCode method n object- setting the hashCode to the width&Length of the rectangle. What I'm trying to do is * make rectangles unique by width & length override public int hashCode) ( return objects.hash(iwidth, Length) * equals. This method is triggered when two objects with the same hashCode are detected. Even though I'n setting hashcode myself, I have to also override the equals method to tell java when one objectsanother. 0verride public boolean equals(object o) if (o-this) return true; if ((o instanceof Rectangle)) return false; Rectangle rec(Rectangle) o; return objects.equals (hashCode(), rec.hashCode(O)