System类统计程序执行时间:
//System.currentTimeMillis,返回 当前时间与协调世界时 1970 年 1 月 1 日午夜之间的时间差(以毫秒为单位测量)
long startTime = System.currentTimeMillis();
for (int i = 0; i < 10000; i++) {
i =+i ;
System.out.println(i);
}
// 记录for循环完成后的 时间点
long endTime = System.currentTimeMillis();
System.out.println("用时:" + (endTime - startTime) + "ms");