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 {
/*w w w.  java  2s.co m*/
   public static void main(String[] args) {

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

   }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable