File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java Collection question

 
Saathvik Reddy
Ranch Hand
Posts: 228
  • 0
  • 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
Pie
Posts: 12015
24
Chrome Java Linux
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Saathvik Reddy
Ranch Hand
Posts: 228
  • 0
  • 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