• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointerException

 
Brian LaRue
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • 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
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator


Thanks for offering your help...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic