-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathGC.java
More file actions
38 lines (34 loc) · 897 Bytes
/
GC.java
File metadata and controls
38 lines (34 loc) · 897 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
class Emp{ // class Emp extends Object
int id;
String name;
Emp(int id, String name){
this.id = id;
this.name = name;
System.out.println("Emp Born...");
}
void print(){
System.out.println("Id "+id+" name "+name);
}
@Override
protected void finalize() throws Throwable{
super.finalize();
System.out.println("Good Bye Emp...");
}
}
public class GC {
public static void main(String[] args) {
Emp emp = new Emp(1001, "ram");
//emp.print();
int x = 10;
int y = 20;
//System.out.println(" Emp is null now...");
emp = null;
System.gc(); // Request to GC to Run....
x++;
y++;
for(int i = 1; i<=5; i++){
System.out.println("I is "+i);
}
//System.out.println("main Ends..");
}
}