系统中的其他方法

原文: https://docs.oracle.com/javase/tutorial/essential/environment/sysmisc.html

本节介绍System中的一些方法,这些方法在前面几节中没有介绍。

arrayCopy方法有效地在数组之间复制数据。有关更多信息,请参阅语言基础知识课程中的数组

currentTimeMillisnanoTime 方法可用于测量应用程序执行期间的时间间隔。要以毫秒为单位测量时间间隔,请在间隔的开始和结束时调用currentTimeMillis两次,并减去从第二个返回的第一个值。同样,调用nanoTime两次测量一个以纳秒为单位的间隔。


Note: The accuracy of both currentTimeMillis and nanoTime is limited by the time services provided by the operating system. Do not assume that currentTimeMillis is accurate to the nearest millisecond or that nanoTime is accurate to the nearest nanosecond. Also, neither currentTimeMillis nor nanoTime should be used to determine the current time. Use a high-level method, such as java.util.Calendar.getInstance.


exit 方法导致 Java 虚拟机关闭,参数指定整数退出状态。退出状态可用于启动应用程序的进程。按照惯例,0的退出状态表示应用程序的正常终止,而任何其他值都是错误代码。