Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions GarbageCollect.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Sample{
Sample(){
System.out.println("Object created");
}

protected void finalize(){
System.out.println("Object destroyed");
}
}
public class GarbageCollect {
public static void main(String[] args) {
Sample obj=new Sample();
obj=null;
Sample one=new Sample();
Sample two=new Sample();
one=two;

System.gc();
}
}
20 changes: 20 additions & 0 deletions Programs/GarbageCollect.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Sample{
Sample(){
System.out.println("Object created");
}

protected void finalize(){
System.out.println("Object destroyed");
}
}
public class GarbageCollect {
public static void main(String[] args) {
Sample obj=new Sample();
obj=null;
Sample one=new Sample();
Sample two=new Sample();
one=two;

System.gc();
}
}