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 {
/*from w ww .j a v a 2s . c o m*/
public static void main(String[] args) {
Runtime.getRuntime().gc();
System.out.println("Completed.");
}
}
The code above generates the following result.