• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

NullPointer Exception

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

 
Marshal
Posts: 80775
489
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic