小天管理 发表于 8月24日 Share 发表于 8月24日 public class Main { public static void main(String[] args) { long startTime = System.nanoTime(); long startTime2 = System.currentTimeMillis(); for (int i = -1; ++i < 1000; ) { String row = "Column 1: " + "1" + ", Column 2: " + "2" + ", Column 3: " + "3" + ", Column 3: " + "4"; System.out.println(row); } long endTime = System.nanoTime(); long endTime2 = System.currentTimeMillis(); long durationInMillis = (endTime - startTime) / 1_000_000; long durationInMillis2 = (endTime2 - startTime2) / 1; System.out.println("Time taken to output the result: " + durationInMillis + " milliseconds"); System.out.println("Time taken to output the result: " + durationInMillis2 + " milliseconds"); }}idea点击运行Time taken to output the result: 6 millisecondsTime taken to output the result: 6 millisecondscmd 命令提示符java Main.javaTime taken to output the result: 143 millisecondsTime taken to output the result: 145 milliseconds 引用 意见的链接 分享到其他网站 More sharing options...
已推荐帖子
加入讨论
您现在可以发表并稍后注册. 如果您是会员,请现在登录来参与讨论.