How to Finalize Object in Java


In this example we will show the method to finalize object in Java.

Source Code

package com.beginner.examples;

public class RunFinalization {

  public static void main(String[] args){
    Runtime run = Runtime.getRuntime();
    run.runFinalization(); // finalize object
    System.out.println("OK!");
  }
}

Output:

OK!
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments