System.gc() in Java

System.gc(): This method is available in java.lang.System class of Java.

Syntax:

void java.lang.System.gc()

This method runs the garbage collector in the Java Virtual Machine.

Parameters: NA

Exceptions: NA

Approach

Java

public class Systemgc {
    public static void main(String[] args) {

        System.gc();

    }
}


No comments:

Post a Comment