File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes java Collection question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "java Collection question" Watch "java Collection question" New topic
Author

java Collection question

Saathvik Reddy
Ranch Hand

Joined: Jun 03, 2005
Posts: 228
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

Joined: Oct 02, 2003
Posts: 10043
    
    6

do you want to prevent null objects from going into the collection, or when the object is null, avoid getting the NPE?


Never ascribe to malice that which can be adequately explained by stupidity.
Minh Tran
Greenhorn

Joined: Jun 03, 2007
Posts: 19


SCJP 1.4, SCWCD 1.4<br />email:mobject@gmail.com
Saathvik Reddy
Ranch Hand

Joined: Jun 03, 2005
Posts: 228
That was simple! Thanks a lot Minh.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: java Collection question
 
Similar Threads
a garbage collection question from K&B self-test
Vector and null
nullifying an object in a generics list collection
Collections
Collection Storing problem