-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectUtility.java
More file actions
30 lines (20 loc) · 826 Bytes
/
Copy pathObjectUtility.java
File metadata and controls
30 lines (20 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package objects;
import java.util.Comparator;
import java.util.Objects;
public class ObjectUtility {
public static void main(String[] args) {
Object a = "deep";
Object b = "deep2";
Object c = null;
System.out.println("equals:" + Objects.equals(a, b));
System.out.println("hash:" + Objects.hash(a, b));
System.out.println("hashCode:" + Objects.hashCode(b));
System.out.println("isNull:" + Objects.isNull(c));
System.out.println("nonNull:" + Objects.nonNull(b));
System.out.println("requireNonNull:" + Objects.requireNonNull(b));// check for null or throw null pointer
// exception
System.out.println("deepEquals:" + Objects.deepEquals(a, b)); // arrays package
Comparator comparator = null;
System.out.println("deepEquals:" + Objects.compare(a, b, comparator));
}
}