• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception in thread  RSS feed

 
Kyle Ruey
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to develop a simple inventory program but I can not even get past the first question of my program without creating an error. This is what I have so far. I marked the line that is giving me the most problem with a 1. If I answer the question with a No the program closes just like its suppose to. If I answer the question Yes then it says Enter the Item Name(like it is supposed to) then when I enter the item name and hit enter it throws a Exception in thread "main" java.lang.NullPointerException.



 
A.J. Côté
Ranch Hand
Posts: 417
Java
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, setInventoryInfo() return null so re is null, hence you get a NullPointerException trying to set re.name.
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please use code tags; I added them for you this time and doesn't it look better Also don't write so many blank lines; I have deleted lots of blanks and also had to guess that the second class it not an inner class.

Why have you got so many things marked static?
Why are you returning null from anywhere; that is a potentially dangerous thing to do, as you have just found out.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!