Ce Blog contient mes notes.
Nullius in verba
« Being a software craftsman is far more than that. It’s commitment to excellence. It’s a lifestyle. At the end of the day, as professionals we are expected to deliver high-quality services to our clients, which is normally achieved via well-crafted software. »- Coman Hamilton -
dimanche 19 mai 2019
Java : Supprimer un element de la liste à l'interieur d'une boucle for (Remove an Element from a List Inside a Loop)
Iterator iter = list.iterator();
while (iter.hasNext()) {
// next() Doit être appelé avant la méthode remove(), sinon la taille (size) de Arraylist va changer.
String s = iter.next();
if (s.equals("a")) {
iter.remove();
}
}
Aucun commentaire:
Enregistrer un commentaire
to criticize, to improve