相关类
Runtime
##Runtime
Runtime runtime = Runtime.getRuntime();
###实现方式
public class Runtime {
private static Runtime currentRuntime = new Runtime();
/**
* Returns the runtime object associated with the current Java application.
*/
public static Runtime getRuntime() {
return currentRuntime;
}
private Runtime() {}
......
}
反射对单例的破坏
Class<Runtime> runtimeClass = Runtime.class;
Constructor<Runtime> runtimeConstructor = runtimeClass.getDeclaredConstructor();
runtimeConstructor.setAccessible(true);
System.out.println(Runtime.getRuntime() == runtimeConstructor.newInstance());
一起学习交流呀