• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

NullPointerException

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)

 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Adithya Bhat wrote:


Hey you have not initialized the res.data so it throws NULL POINTER Exception.
 
Marshal
Posts: 71098
292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys,code's working now.
But i don't get what Campbell is saying.
 
Campbell Ritchie
Marshal
Posts: 71098
292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Campbell,now i get what you are saying.
 
Campbell Ritchie
Marshal
Posts: 71098
292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome

And welcome as a new member to JavaRanch
 
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic