• 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

NullPointerException

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
after creating my class, at run-time, I'm getting a NullPointerException. I'm wondering why this is occuring. JVM doesn't like my array for some reason.
Here's my code so far:



What am I doing wrong? Any help is greatly appreciated.

Brian
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Brian,

The stack trace should tell you exactly what line of what file the NullPOinterException occurs on; can you tell show us exactly that line of code?
 
Brian LaRue
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Thanks for offering your help...
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
remove the semicolon :
while ((line = bfr.readLine()) != null); {

Be careful 1) You should check the size of the array returned by the split method.
Be careful 2) You are declaring a array of 4 elements, while trying access 5

In fact, you don't even need to declare a new instance.
Just do :

and check the size of the array with parts.length
[ February 16, 2006: Message edited by: Satou kurinosuke ]
 
Brian LaRue
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Awe man, I'm an idiot. I should have guessed that it was something obvious! Doh! That did it, thanks for the insight!
reply
    Bookmark Topic Watch Topic
  • New Topic