package com.liuc; public class AutoPackage { public static void main(String[] args) { long start=System.currentTimeMillis(); long sum = 0L; for (int i = 0; i < Integer.MAX_VALUE; i++) { sum += i; } long end=System.currentTimeMillis(); System.out.println((end-start)/1000); } }
运行时间19S
和下面这个程序package com.liuc; public class AutoPackage { public static void main(String[] args) { long start=System.currentTimeMillis(); Long sum = 0L; for (int i = 0; i < Integer.MAX_VALUE; i++) { sum += i; } long end=System.currentTimeMillis(); System.out.println((end-start)/1000); } }
运行时间19S