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

NullPointerException

Adithya Bhat
Greenhorn

Joined: Nov 06, 2009
Posts: 9
Hello guys i was working with multidimensional array and when i try to execute this following program i get this error.Can you guys please help me with this one.

java.lang.NullPointerException
at blur.copy(blur.java:15)
at blur.main(blur.java:30)

Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1756
    
    7

What do you suppose the data memer variable of the multi object created at line 10 refers to after the constructor completes?
Does that change anywhere in the body of the copy method?

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Vivek Singh
Ranch Hand

Joined: Oct 27, 2009
Posts: 92
Adithya Bhat wrote:

Hey you have not initialized the res.data so it throws NULL POINTER Exception.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
Go through every object reference in that line (15) and insert a line before it rather like this
That will tell you which object was null. You may be able to miss out the != null bits in that line.
Adithya Bhat
Greenhorn

Joined: Nov 06, 2009
Posts: 9
Thank you guys,code's working now.
But i don't get what Campbell is saying.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
This is your code with one line added:Correct the spelling and compiler errors (if any), run that, and see whether you get a helpful output just before the Exception.>
Adithya Bhat
Greenhorn

Joined: Nov 06, 2009
Posts: 9
Thanks Campbell,now i get what you are saying.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
You're welcome

And welcome as a new member to JavaRanch
 
jQuery in Action, 2nd edition
 
subject: NullPointerException
 
Similar Threads
Head First Java - Can't understand the output
GUI display(rendering) problem
methods with parameters
array[] [] ?
some silly questions