Q:

How to remove null bean attributes present in a List?

I am using Spring-WS to populate a List<SomeBean> w.r.t. a web-service. The final list that I get after consuming the service contains null entries for some of its properties. For example, consider the following list of MangaBean which has title, author and genre as properties.
MangaBean [title=Bleach, author=Kubo Tite, genre=fantasy]
MangaBean [title=Naruto, author=Masashi Kishimoto, genre=action]
MangaBean [title=One Piece, author=Eiichiro Oda, genre=null]
MangaBean [title=Fairy Tail, author=Mashima Hiro, genre=null]
MangaBean [title=Rurouni Kenshin, author=Watsuki Nobuhiro, genre=Shounen]
MangaBean [title=Takamagahara, author=KAWAI Juuzou, genre=Supernatural]
MangaBean [title=Historys Strongest Disciple Kenichi, author=Matsuena Syun, genre=Martial arts]
MangaBean [title=Hajime no Ippo, author=Jyoji Morikawa, genre=null]

The genre entry for some beans are null. I am trying to remove the objects with null properties in the list. 
My questions are:

Is it proper/good practice to alter the original list by removing specific entries? Or should I populate another list w.r.t. the previous list?
If I should alter the list and remove those null entries, how should I do it?

I tried this but it fails as the object-refs themselves aren't null. I tried the traditional for loop but it fails to remove adjucent objects with null properties. Cannot use the enhanced-for-loop for removing items while accessing the list. Kindly render me some brain. :)

A:

You can use an Iterator and remove the one having a null genre manually:
for (Iterator<MangaBean> it = mangas.iterator(); it.hasNext();) {
    if (it.next().getGenre() == null) { 
        it.remove(); 
    }
}

Or you could filter the list using some common libraries like Apache Commons CollectionUtils, or Guava Iterables.filter():
// apache commons
mangas = CollectionUtils.filter(mangas, new Predicate() {
    @Override public boolean evaluate(Object object) {
        return ((Manga) manga).getGenre() != null;
    }
});

// Guava 
Iterables.filter(mangas, new Predicate<Manga>() {
    @Override public boolean apply(Manga m) {
        return manga.getGenre() != null;
    }
});

