Java List遍历方法 及其效率对比
One:14109
Two:14000
Three:15141
four:14297
package com.zbalpha.test;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class ListTest {
public static void main(String args[]){
List<Long> lists = new ArrayList<Long>();
for(Long i=0l;i<1000000l;i++){
lists.add(i);
}
Long oneOk = oneMethod(lists);
Long twoOk = twoMethod(lists);
Long threeOk = threeMethod(lists);
Long fourOk = fourMethod(lists);
System.out.println("One:" + oneOk);
System.out.println("Two:" + twoOk);
System.out.println("Three:" + threeOk);
System.out.println("four:" + fourOk);
}
public static Long oneMethod(List<Long> lists){
Long timeStart = System.currentTimeMillis();
for(int i=0;i<lists.size();i++) {
System.out.println(lists.get(i));
}
Long timeStop = System.currentTimeMillis();
return timeStop -timeStart ;
}
&
相关文档:
正则表达式是字符串处理的终极武器,本文以一个具体题目简介java对正则表达式的支持。
题目:将一个字符串中的形如href=“XXXX”和 src=“XXXX”的部分取出,打印。
处理正则表达式主要用到java.util.regex.Matcher和 java.util.regex.Pattern两个类。
\\测试用的字符串
String source= "...h ......
线程池类为 java.util.concurrent.ThreadPoolExecutor,常用构造方法为: ThreadPoolExecutor(int corePoolSize, int maximumPoolSize,
long keepAliveTime, TimeUnit unit,
BlockingQueue<Runnable> workQueue,
RejectedExecutionHandler handler) corePoolSize: 线程池维护线程的最少数量 ......
关键字: json java
JSON-lib这个Java类包用于把bean,map和XML转换成JSON并能够把JSON转回成bean和DynaBean。
下载地址:http://json-lib.sourceforge.net/
还要需要的第3方包:
org.apache.commons(3.2以上版本)
org.apache.oro
net.sf.ezmorph(ezmorph-1.0.4.jar)
nu.xom
1、List
Java代码
boolean[] bool ......
安装开发环境
ubuntu9.10下安装JAVA开发环境其实还是比较简单的,我们就以安装常用的jdk、eclipse、tomcat、svn client(找到一个可以和windows中的小乌龟类似的但安装还有点问题解决后会补上)、oracle client为例讲讲如何安装(本文中自动化安装脚本下载http://download.csdn.net/source/2034239,文件太大分成6份 )。前 ......
整体系统采用Java中Spring ,Struts, Hibernate组成。
在Action中:
public ActionForward orgview(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) {
// TODO Auto-generated method stub
ActionForward forward = new ActionForward("strpath");
Http ......