How to Run an Object Finalization in Java


The example aims to run an object finalization in Java.

Source Code

package com.beginner.examples;


public class RunOFExample {

    public static void main(String[] args){
    	
    	Runtime run = Runtime.getRuntime();
    	//garbage collect
    	run.runFinalization();
		System.out.println("Object finalization is done!");
    }
    
}

Output:

Object finalization is done!
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments