文件名称:android中几种for循环的效率
文件大小:1017KB
文件格式:ZIP
更新时间:2016-10-20 11:33:39
for循环效率 在网上看了一些for循环的效率问题,发现基本上都是一些理论的东西,且大多都是Copy来的,前后文自相矛盾。自己做了一个例子,来看看他们的效率 1.最慢 private long getTime1() { long time = 0; int count = 0; long timenow = System.currentTimeMillis(); for (String str : strs) { count++; } return System.currentTimeMillis() - timenow; } 2.比较慢 private long getTime2() { long time = 0; int count = 0; long timenow = System.currentTimeMillis(); for (int i=0;i