所以,如果這是我的課程:如何從Arraylist中刪除隨機對象?
我的問題是,在步驟()函數的條件2,我該如何從數組列表中刪除該對象?我不確定,因爲隨機選擇隨機函數
import java.util.Random;
public class test{
private ArrayList<list> holder;
public class(){
int i = 0;
holder = new ArrayList<Student>();
for (i=0;i<S;i++){
holder.add(new holder(i, library));
}
}
public void step(){
box = students.get(random.nextInt(holder.size()));
if (condition 1){
do this
} else if (condition 2){
** remove the random object from arraylist (how?)**
}
}