Tag: javacompiler

Java for循环优化

我用java for循环做了一些运行时测试,并发现了一个奇怪的行为。 对于我的代码,我需要原始类型的包装器对象,如int,double等,以模拟io和输出参数,但这不是重点。 只需看我的代码。 具有字段访问权限的对象如何比原始类型更快? 具有prtimitive类型的for循环: public static void main(String[] args) { double max = 1000; for (int j = 1; j < 8; j++) { double i; max = max * 10; long start = System.nanoTime(); for (i = 0; i < max; i++) { } long end = System.nanoTime(); long microseconds = (end […]