Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9215771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:16:38+00:00 2026-06-18T02:16:38+00:00

I am using Spring-WS to populate a List<SomeBean> w.r.t. a web-service. The final list

  • 0

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:

  1. 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?
  2. 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. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:16:40+00:00Added an answer on June 18, 2026 at 2:16 am

    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;
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Spring MVC with Hibernate. My page has a button that creates
I am using Spring to populate a item in a form, using object passing
I have FileInfo[] fileInfos I want to populate string[] filesNames and List<string> fileNamesList using
I'm using a Linq DataContext.ExecuteQuery(some sql statement) to populate a list of objects var
I'm using play-2.0.3. I have a Map and want to populate dropdown-list with Int->String
I populate a list of <form> using a PHP while loop, and fill the
I've built an AlertDialog using a cursor to populate the list items in the
Im trying to get a list of line items to a webpage using JSON,
Using Spring 2.5 tag library, I have an Integer value in a command form
When using spring security, specifically with @notation; what is the proper way to access

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.