aspose file tools*
The moose likes JDBC and the fly likes Nullpointer exception? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Nullpointer exception?" Watch "Nullpointer exception?" New topic
Author

Nullpointer exception?

Jyoti Vaskar
Ranch Hand

Joined: Jun 30, 2009
Posts: 142
Can anybody solve this problem???

I am trying to store the data from database(table jyoti) in a bean
& then adding the bean into an arraylist.

here is my code:



what's wrong with the above code?
I am getting Nullpointer exception?
it's stucking up after
System.out.println(al);

(above line prints null) for al.add(eb) it stucks? ?


thanks
Jyo
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

You haven't initialised the ArrayList anywhere.

Sean


I love this place!
Jyoti Vaskar
Ranch Hand

Joined: Jun 30, 2009
Posts: 142
where it matters ?
doesn't it take the default value null?? As its instance variable??
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Yes, but you can't call methods on a variable that is null.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

Objects start as null until they are initialized. Since an ArrayList is an object, you must initialize it else its just a null pointer.


My Blog: Down Home Country Coding with Scott Selikoff
Jyoti Vaskar
Ranch Hand

Joined: Jun 30, 2009
Posts: 142

thank you guys .

I got my problem & I'm sort with it.

thank you!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Nullpointer exception?