System
方法
数组相关
arraycopy
Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array.
从源数组中的指定位置开始 到 目标数组的指定位置开始,
public static native void arraycopy(Object src, int srcPos, Object dest, int destPos, int length);
src: the source array. 源数组
srcPos: starting position in the source array. 源数组的起始位置
dest: the destination array. 目标数组
destPos: starting position in the destination data. 目标数组的起始位置
length: the number of array elements to be copied. 被拷贝的数组元素数量
时间相关
currentTimeMillis
Returns the current time in milliseconds.
Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger.
以ms为单位,返回当前时间;
从 1970 年 1 月 1 日 00:00:00 UTC(协调世界时)开始到现在经过的毫秒数;
精度是毫秒(1/1000秒)
public static native long currentTimeMillis();
使用场景:
处理日期、时间戳或者与实际世界时间相关的操作,应该使用 System.currentTimeMillis()
nanoTime
Returns the current value of the running Java Virtual Machine's high-resolution time source, in nanoseconds.
以纳秒为单位,返回当前JVM
This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time.
The value returned represents nanoseconds since some fixed but arbitrary <i>origin</i> time (perhaps in the future, so values may be negative).
只能用于测量经过的时间;
返回的时间 表示 从某个固定的任意时间 到 现在经过的纳秒数;
精度是纳秒(1/1,000,000,000秒)
public static native long nanoTime();
使用场景:
精确地测量代码片段的执行时间,尤其是在进行性能分析或优化时,应使用 System.nanoTime()
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)