| Author |
NullPointerException occured
|
Ben Hultin
Ranch Hand
Joined: Aug 17, 2009
Posts: 135
|
|
I did some research on my exception I found, but I cant figure out how to solve the issue.
my error:
C:\Documents and Settings\ben\Desktop\park> java BenHultinProg7
Exception in thread "main" java.lang.NullPointerException
at Prog7.<init>(Prog7.java:32)
at BenHultinProg7.main(BenHultinProg7.java:12)
C:\Documents and Settings\ben\Desktop\park>
here is my driver class:
here is my driven class:
Thanks a lot for the help
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
|
The NPE says exactly which line is causing it: Line 32 of Prog7.java. In this case, it's The reason? You never assign anything to field1. Or any of the other fields, for that matter.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Christiaan Lombard
Greenhorn
Joined: Nov 22, 2009
Posts: 26
|
|
Fix:
Add this right before:
|
SCJP 6
|
 |
 |
|
|
subject: NullPointerException occured
|
|
|