使用System.nanoTime获取当前时间。
long startTime = System.nanoTime();.....your program....long endTime = System.nanoTime();long totalTime = endTime - startTime;System.out.println(totalTime);
上面的代码以纳秒为单位打印程序的运行时间。

使用System.nanoTime获取当前时间。
long startTime = System.nanoTime();.....your program....long endTime = System.nanoTime();long totalTime = endTime - startTime;System.out.println(totalTime);
上面的代码以纳秒为单位打印程序的运行时间。