日期:2014-05-20 浏览次数:20888 次
public class Add{
public int getAdd(int a,int b){
int x= a+b;
return ;
}
}
参数值放在list时调用该方法,将运算后的结果放入到list里
List l = new ArrayList();
Add a = new Add();
for(int i = 0 ; i <list.size();i++){
int m = a.getAdd(list1.get(i),list2.get(i));
l.add(m);
}
public void getAdd(List<Integer> aList,List<Integer> bList, List<Integer> resultList){
if((null != aList) && (null != bList)){
int minSize = aList.size()< bList.size()?aList.size():bList.size();
for(int i=0; i < minSize; ++i) {
resultList.add(aList.get(i) + bList.get(i));
}
}
}