public static void main(String[] args) {
// TODO Auto-generated method stub
int MAX = 2000000;
long sg = System.currentTimeMillis();
Long sum = 0L;
for(long i = 0;i<MAX;i++)
sum += i;
System.out.println(System.currentTimeMillis() - sg);
sg = System.currentTimeMillis();
long sum1 = 0L;
for(int i = 0;i<MAX;i++)
sum1 += i;
System.out.println(System.currentTimeMillis() - sg);
}
输出:
61
5
可见,如果将包装类和基本类进行运算要先拆t箱运算完再进行装箱操作