public class DuffDevice { private static long duff2(long count) { long i = 0; do { ++i; } while (--count >0); return i; } public static void main(String[] args) { long duff; long start, end; DuffDevice duffDevice = new DuffDevice(); start = System.currentTimeMillis(); duff = duff2((long) Integer.MAX_VALUE - 7); end = System.currentTimeMillis(); System.out.println(duff + " " + (end - start) + " ms"); } } 输出 2147483640 639 ms 我改了一下 i 值的类型 耗时 变长了 所以 应该没把循环优化掉吧