• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception in thread

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.



 
Ranch Hand
Posts: 417
Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, setInventoryInfo() return null so re is null, hence you get a NullPointerException trying to set re.name.
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic