Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final class Item {
- Integer size;
- Item(Integer size) { this.size = size; }
- public boolean equals(Item item2) {
- if (this == item2) return true;
- return this.size.equals(item2.size);
- }
- }
- public class SkepticRide {
- public static void main(String[] args) {
- Item itemA = new Item(10);
- Item itemB = new Item(10);
- Object itemC = itemA;
- System.out.println("|" + itemA.equals(itemB) +
- "|" + itemC.equals(itemB) + "|");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement