-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainEqHash.java
More file actions
23 lines (20 loc) · 791 Bytes
/
MainEqHash.java
File metadata and controls
23 lines (20 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package EqualsHashCode;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
public class MainEqHash {
public static void main(String[] args) {
TestObject testObject = new TestObject("Test1",12);
TestObject testObject1 = new TestObject("Test1",12);
List<TestObject> list = new ArrayList<>();
list.add(testObject);
list.add(testObject1);
System.out.println(list.contains(new TestObject("Test1",12)));
HashSet< TestObject > hash = new HashSet < TestObject > ();
hash.add(testObject);
hash.add(testObject1);
//eger hashCode overriding edilmemisse equal yetmiyor
System.out.println(hash.size());
System.out.println(hash.contains(new TestObject("Test1",12)));
}
}