Java Data Type Tutorial - Java Runtime.maxMemory()








Syntax

Runtime.maxMemory() has the following syntax.

public long maxMemory()

Example

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

public class Main {

   public static void main(String[] args) {

      // print the maximum memory
      System.out.println(Runtime.getRuntime().maxMemory());

   }
}

The code above generates the following result.