wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes List question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "List question" Watch "List question" New topic
Author

List question

John Olivas
Greenhorn

Joined: Jul 19, 2010
Posts: 2
My question is why do I throw an exception every time I try to add data to my List?

method below, thanks!

pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
You need to show the exact expression information that is returned and indicate which line is throwing it to get better help. So for now I can only guess that you're getting a NullPointerException as you never initialize the result List<String>.

For instance, I would change this:


to this:


ps: I added code tags to your post to help make it readable. The forum FAQ's will show you how to do this yourself: UseCodeTags

ps2: Please let me be the first to welcome you to JavaRanch!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

(And make sure you close the connection, and don't over-comment.)
John Olivas
Greenhorn

Joined: Jul 19, 2010
Posts: 2
Thank you both. I will add the code tags and remove the excess comments before posting.

And yes you were correct, initializing the List did the trick.
 
 
subject: List question