Besides all the excellent solutions offered here I would like to offer a different solution.
I'm not sure if you're free to add dependencies, but if you can, you could add the https://code.google.com/p/guava-libraries/ as a dependency. This library adds support for many basic functional operations to Java and can make working with collections a lot easier and more readable.
In the code I replaced the type of the List by T, since I don't know what your list is typed to.
This problem can with guava be solved like this:
List<T> filteredList = new Arraylist<>(filter(list, not(XXX_EQUAL_TO_AAA)));
And somewhere else you then define XXX_EQUAL_TO_AAA as:
public static final Predicate<T> XXX_EQUAL_TO_AAA = new Predicate<T>() {
@Override
public boolean apply(T input) {
return input.getXXX().equalsIgnoreCase("AAA");
}
}
However, this is probably overkill in your situation. It's just something that becomes increasingly powerful the more you work with collections.
Ohw, also, you need these static imports:
import static com.google.common.base.Predicates.not;
import static com.google.common.collect.Collections2.filter;