package com.qingruxu.test;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.qingruxu.opendb.open;
import com.qingruxu.vo.EcsGoods;
public class Main {
public static void main(String[] args) {
ApplicationContext content=new ClassPathXmlApplicationContext("applicationContext.xml");
open op=(open) content.getBean("open");
//op.selectGoods();
List data =op.getGoods(35, 1);
long start=System.nanoTime();
for(int i=0;i<data.size();i++)
{
EcsGoods ecs=(EcsGoods) data.get(i);
}
long stop=System.nanoTime();
System.out.println("for用时:"+(stop-start));
Iterator it= data.iterator();
start=System.nanoTime();
while(it.hasNext()){
EcsGoods ecs=(EcsGoods) it.next();
}
stop=System.nanoTime();
System.out.println("Iterator用时:"+(stop-start));
start=System.nanoTime();
for (Object object : data) {
EcsGoods ecs=(EcsGoods) object;
}
stop=System.nanoTime();
System.out.println("foreach用时:"+(stop-start));
}
}
- 上一篇:JAVA导出Excel电子表格的方法
- 下一篇:Jdbc-Java源码