class RuntimeTest
{
public static void main(String[] args)
{
Runtime rt=Runtime.getRuntime();
System.out.println("JVM 自由内存:"+rt.freeMemory());
System.out.println("JVM 总内存:"+rt.totalMemory());
System.out.println("JVM 试图使用的最大内存量:"+rt.maxMemory());
// 这 JVM 试图使用的最大内存量 是指什么?结果上G了,我硬件配置远远满足不了。
try
{
rt.exec("notepad"); // 其他的应用程序名要怎么知道?
}
catch(Exception e)
{
e.printStackTrace();
}
}
}class Singleton {
private static final Singleton st=new Singleton();
private Singleton(){}
public static Singleton getInstance()
{
return st;
}
}
{
public static void main(String[] args)
{
Runtime rt=Runtime.getRuntime();
System.out.println("JVM 自由内存:"+rt.freeMemory());
System.out.println("JVM 总内存:"+rt.totalMemory());
System.out.println("JVM 试图使用的最大内存量:"+rt.maxMemory());
// 这 JVM 试图使用的最大内存量 是指什么?结果上G了,我硬件配置远远满足不了。
try
{
rt.exec("notepad"); // 其他的应用程序名要怎么知道?
}
catch(Exception e)
{
e.printStackTrace();
}
}
}class Singleton {
private static final Singleton st=new Singleton();
private Singleton(){}
public static Singleton getInstance()
{
return st;
}
}
rt.exec("notepad"); // 其他的应用程序名要怎么知道? 比如画图程序名是什么?
rt.exec("notepad"): 应该是对于系统的命令就可以吧,如rt.exec("regedit");打开win注册表。
最后一个是一个单例啊,看看设计模式。