-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo.java
More file actions
48 lines (40 loc) · 903 Bytes
/
Demo.java
File metadata and controls
48 lines (40 loc) · 903 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
43
44
45
46
47
48
package com.tyss.defaultobjectclass;
import java.util.LinkedList;
public class Demo {
@Override
public String toString() {
return "Object is from demo";
}
@Override
public boolean equals(Object obj) {
if(obj instanceof LinkedList<?>) {
return true;
}else {
return false;
}
}
//@Override
//public int hashCode{
// return 1;
//}
@Override
protected void finalize() throws Throwable{
System.out.println("this is from finalize");
}
public static void main(String[] args) {
Demo demo = new Demo();
demo.toString();
System.out.println(demo);
Demo demo1=new Demo();
System.out.println("this is the object of second ref\n"+demo1);
boolean equals=demo1.equals(demo1);
System.out.println(equals);
demo=null;
Demo demo2=new Demo();
int hashCode=demo2.hashCode();
System.out.println(hashCode);
demo1=null;
demo2=null;
System.gc();
}
}