I need to delete some objects from an ArrayList if they meet a condition and I\'m wondering which way could be more efficient.
Here\'s the situation: I
Unless you're positive that the issue you're facing is indeed a bottleneck, I would go for the readable
public ArrayList filterThings() {
ArrayList pileOfThings;
ArrayList filteredPileOfThings = new ArrayList();
for (Thing thingy : pileOfThings) {
if (thingy.property != 1) {
filteredPileOfThings.add(thingy);
}
}
return filteredPileOfThings;
}