Advertisement
IlushaBeletskiy

Untitled

Dec 15th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. public class Test {
  2.  
  3.     private int id;
  4.     private int age;
  5.  
  6.     public Test(int id, int age) {
  7.         this.id = id;
  8.         this.age = age;
  9.     }
  10.  
  11.     public boolean equals(Object o) {
  12.         Test otherTest = (Test) o;
  13.         return otherTest.id == this.id;
  14.     }
  15.    
  16.     public String toString() {
  17.         return "айди  - " + this.id;
  18.     }
  19.  
  20.     @Override
  21.     public int hashCode() {
  22.         return this.id * 12345;
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement