• Post Reply Bookmark Topic Watch Topic
  • New Topic

NullPointer Exception  RSS feed

 
john-paul York
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seems I make progress...need help..make some progress..and need more help....I am getting a nullPointerException for a project I am doing...I want to display all the info in each object that is in each order, so I got it to work if I fill the max number of items out, but if I don't fill the array it throws a nullPointer. I tried using a counter whenever a object was added and then during the display function just looping through with the max being that counter, but that did not seem to work. Any suggestions

 
Campbell Ritchie
Marshal
Posts: 55768
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you create an array and don't fill it, that array will be full of null references. If you try to use those null references, you are liable to suffer a NullPointerException. So you want to fill any arrays as soon as possible after creation.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!