我想知道这个方法是如何remove(Object e)
工作的。我有这个代码:
Vector<Actor> toChoose;
Vector<Actor> toDelete;
toDelete = film.getActors();
toChoose = db.getActors();
System.out.println("To Delete:");
for (int i = 0; i < toDelete.size(); i++){
System.out.println(toDelete.get(i).getName());
}
System.out.println("===============");
System.out.println("To choose:");
for (int i = 0; i < toChoose.size(); i++){
System.out.println(toChoose.get(i).getName());
}
System.out.println("===============");
for (int i = 0; i < selectedActors.size(); i++){
toChoose.remove((Actor) selectedActors.get(i));
}
System.out.println("To choose after deleting:");
for (int i = 0; i < toChoose.size(); i++){
System.out.println(toChoose.get(i));
}
System.out.println("===============");
这是输出:
To Delete:
Angelina Jolie
Louis de Funes
===============
To choose:
Angelina Jolie
Louis de Funes
Lukáš Hamrla
Brad Pitt
===============
To choose after deleting:
Angelina Jolie
Louis de Funes
Lukáš Hamrla
Brad Pitt
===============
我想这显然是我想要的。我不知道如何从中toDelete
删除对象toChoose
。