This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java Collection question

 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a collection which is like {obj1, null, obj3}. This collection is the result of a database query.
when i am trying to access the 2nd object(which is null) i am getting NPE. How can i filter the collection for null values?

Thanks in advance.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12342
39
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do you want to prevent null objects from going into the collection, or when the object is null, avoid getting the NPE?
 
Minh Tran
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was simple! Thanks a lot Minh.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!