IMHO, le plus simple/logique/classique/explicite c'est de créer une nouvelle arraylist et de n'y mettre que les éléments à garder ![:o :o](https://forum-images.hardware.fr/icones/redface.gif)
Et avec les Google Collections, ça devient franchement facile (modulo la syntaxe bien verbeuse de java):
Code :
final List<T> out = new ArrayList<T>(Iterables.filter(in, new Predicate<T>() { boolean apply(final T value) { return doWeKeep(value); }}));
|
Tu peux aussi le faire avec un foreach classique, si tu préfères ![:o :o](https://forum-images.hardware.fr/icones/redface.gif)
Message édité par masklinn le 26-03-2009 à 12:53:50
---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box, and replicate and expand beyond their wildest dreams by throwing away the limits imposed by overbearing genetic r