Win a copy of Terraform in Action this week in the Cloud forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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: 74388
334
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic