java LinkedList 循环100000次怎么改

2025-01-31 19:45:23
推荐回答(2个)
回答1:

Iterator it = lkl.iterator();
int i=1;
while(it.hasNext() && i <=100000){
int s = (int) it.next();
//System.out.println(s);
Sum=Sum+s;
i++;
}

回答2:

Iterator it = lkl.iterator();
while(it.hasNext()){
int s = (int) it.next();
//System.out.println(s);
Sum=Sum+s;
for(int i=1;i<100000;i++){
Sum=Sum+s;
}
}