bukebuhao/
共39个网摘 [
1 2 ]
下一页 |
访问bukebuhao的个人空间
bukebuhao收录,时间:2007-12-5 17:17:23 | 相关网摘,我也收藏
/**
* 获取两个整型数组之间的重复元素集合
* @param array1 数组参数1
* @param array2 数组参数2
* @return
*/
public List findSame(int array1[],int array2[]){
List result=new ArrayList();//重复元素结果集合
HashMap hashMap=new HashMap();//利用hashmap来寻找重复元素
for(int i=0;i String temp=array1[i] "";
hashMap.put(temp,temp);
}
for(int i=0;i String temp=array2[i] "";
if(hashMap.get(temp)!=null){//在已经存在第一个数组所有元素的hashmap里寻找第二数组里的元素
result.add(array2[i]);//将重复出现的元素加入结果集合
}
}
return result;
}
public static void main(String args[]){
long timeBegin=System.c
http://topic.csdn.net/u/20071205/11/3610a517-5e42-47ce-9283-544f8eb28c51.html
共39个网摘 [
1 2 ]
下一页