Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Write A Java Program to Explain Garbage Collection With finalize() Method
- public class Ex5
- {
- public static void main(String args[])
- {
- Ex5 obj = new Ex5();
- obj = null;
- Ex5 a = new Ex5();
- Ex5 b = new Ex5();
- b = a;
- System.gc();
- }
- //Optional Method
- /* public void finalize()
- {
- System.out.println("Garbage Collection is Performed By JVM public");
- } */
- protected void finalize() throws Throwable
- {
- System.out.println("Garbage Collection is Performed By JVM Protected");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement