-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExerciseObject.java
More file actions
42 lines (32 loc) · 979 Bytes
/
ExerciseObject.java
File metadata and controls
42 lines (32 loc) · 979 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
31
32
33
34
35
36
37
38
39
40
41
42
package com.zipcodewilmington.javazipbook1;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author kristofer
*/
public class ExerciseObject {
ExerciseObject() {
}
public static void exercise() {
Object obj1 = new Object();
Object obj2 = new Object();
print(obj1.equals(obj1)); // true
print(obj1.equals(obj2)); // false
try {
Object obj3 = obj1.clone();
print(obj3.equals(obj1)); // true
} catch (CloneNotSupportedException ex) {
Logger.getLogger(ExerciseObject.class.getName()).log(Level.SEVERE, null, ex);
}
print(obj1.getClass().getName()); //Object
print(obj1.hashCode(), obj2.hashCode());
print(obj1.toString());
}
public static void print(Object... things) {
for (Object o : things) {
System.out.print(o);
}
System.out.println();
}
}