小编Shu*_*ham的帖子

为什么跳过 for 循环?

long start = System.currentTimeMillis();
long m = 0;
System.out.println("Going into the loop");

for (int i = 0; i < 10000000; i++) {
    for (int j = 0; j < 1000; j++) {
        if (i % 2 == 0 && j % 3 == 0) {
            m = i + j;
        }
    }
}

System.out.println("Out of the loop");

long end = System.currentTimeMillis();
System.out.println("Time : " + (end - start));
System.out.println("m : " + m);
Run Code Online (Sandbox Code Playgroud)

当我运行上面的代码时,“m”的值评估为 10000997,运行时间为 13321。

Going into the loop …
Run Code Online (Sandbox Code Playgroud)

java jvm

3
推荐指数
1
解决办法
102
查看次数

标签 统计

java ×1

jvm ×1