I wanted from java pro out there the best way to remove items from list?
The scenario I have been working with is lets say I have list of object Balls and I want to remove all the balls that have color "RED"
Ball {
private String Color;
}
The best way I can come up with is
Iterator<Balls> i = lst.iterator();
while (i.hasNext()) {
if (i.next().getColor().equals("RED")) {
i.remove();
}
return lst;
I wanted to know if there is better/more concise way to do this, using Collections or any other library. Please keep in mind I am writing for Android so cannot use streams from Java 8 yet. I am using retrolambda however, but it still dose not support streams yet.