Provides access to system-related information and resources including standard input and output.
System类提供对与系统相关的信息和资源的访问,包含一个标准的输入流和输出流。
Enables clients to dynamically load native libraries.
使客户(开发者)能够动态地加载本地函数库。
All methods of this class are accessed in a static way and the class itself can not be instantiated.
System类的所有方法和属性都是静态的,类本身不能被实例化。
静态块初始化静态成员
static {
err = new PrintStream(new FileOutputStream(FileDescriptor.err));
out = new PrintStream(new FileOutputStream(FileDescriptor.out));
in = new FileInputStream(FileDescriptor.in);
// 获取系统的行分隔符,此方法最终会调用initSystemProperties()方法初始化systemProperties属性
lineSeparator = System.getProperty("line.separator");
}
exit退出程序
/**
* 使虚拟机停止运行,并退出程序;
* 此方法在退出程序前会先执行回收垃圾处理;
* 传入的c

本文深入解析了Java中的System类,介绍了其提供系统信息和资源访问的功能,如标准输入输出流,动态加载本地库的能力,以及静态方法的使用,包括静态块、退出程序、获取环境变量和系统属性等关键操作。
最低0.47元/天 解锁文章
790

被折叠的 条评论
为什么被折叠?



