Runtime.gc() has the following syntax.
public void gc()
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.