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 ip地址转换为长整型;
public class Util {
/**
* 字符串ip转换为long
* @param 字符串ip
* @return
*/
public static long getStr ......
public static void replaceString(String source,String oldStr,String newStr){
System.out.println(source);
String result = source.replaceAll("(?i)"+oldStr
, newStr); //大小写不敏 ......
安装开发环境
ubuntu9.10下安装JAVA开发环境其实还是比较简单的,我们就以安装常用的jdk、eclipse、tomcat、svn client(找到一个可以和windows中的小乌龟类似的但安装还有点问题解决后会补上)、oracle client为例讲讲如何安装(本文中自动化安装脚本下载http://download.csdn.net/source/2034239,文件太大分成6份 )。前 ......
很久没上来了,发现虽然资料和书看的很多,但是很久没碰的东西还是很容易淡忘。以后希望能多记录吧。
今天玩了把线程池,并对其中的参数做了一些调整,并记录在多并发情况下线程数对各种情况的反应。程序是网上找的,并作了稍微修改。
java的线程池实现,ThreadPool
package net.zj.hz.yk.thr ......
最近有网友问:如何让一个JAR文件随JVM启动时运行?java.exe是不能够做成这样的,不过可以自己定制java.exe,定制java.exe在如下情况有用:
1.不想程序的进程名显示为java.exe
2.希望程序双击就可以运行。
下面是一段示例代码:
// JVM_CPP.cpp : Defines the entry point for the console application.
//
#include ......