static Runtime getRuntime()
描述 (Description)
java.lang.Runtime.getRuntime()方法返回与当前Java应用程序关联的运行时对象。 类Runtime的大多数方法都是实例方法,必须根据当前运行时对象进行调用。
声明 (Declaration)
以下是java.lang.Runtime.getRuntime()方法的声明
public static Runtime getRuntime()
参数 (Parameters)
NA
返回值 (Return Value)
此方法返回与当前Java应用程序关联的Runtime对象。
异常 (Exception)
NA
例子 (Example)
以下示例显示了lang.Runtime.getRuntime()方法的用法。
package com.iowiki;
public class RuntimeDemo {
public static void main(String[] args) {
// print when the program starts
System.out.println("Program starting...");
// get the current runtime assosiated with this process
Runtime run = Runtime.getRuntime();
// print the current free memory for this runtime
System.out.println("" + run.freeMemory());
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
Program starting...
62780856