Java Data Type Tutorial - Java Runtime.gc()








Syntax

Runtime.gc() has the following syntax.

public void gc()

Example

In the following code shows how to use Runtime.gc() method.

public class Main {

   public static void main(String[] args) {


      Runtime.getRuntime().gc();
      System.out.println("Completed.");
   }
}

The code above generates the following result.