我有这个简单的程序,我需要element从数组列表中删除并更新循环中的大小.
dist fin并且tab2是arrays lists
int k=2;
int count =0;
int temp,num;//lets say this 2 vars are known and positive
while (k > 0){
while(count < dist.size()){
double num=dist.get(count);
if (temp>num){
temp = num;
}
count++;
}
int e = dist.indexOf(temp);
fin.add(tab2.get(e));
dist.remove(e);
System.out.print(fin);
System.out.print(dist);
System.out.print(dist.size());
k--;
}
Run Code Online (Sandbox Code Playgroud)
这只给我一次迭代,然后停止.