集合问题

边遍历边删除,if判断里面size--,i--

public void finishOne(ClassactivityClass){

int size =mActivities.size();

for (int i =0; i < size; i++) {

Activity activity =mActivities.get(i);

if (activity.getClass().getCanonicalName().equals(activityClass.getCanonicalName())) {

mActivities.remove(i);

activity.finish();

i--;

size--;

}

}

}

你可能感兴趣的:(集合问题)