aspose file tools*
The moose likes Beginning Java and the fly likes NullPointerException occured Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NullPointerException occured" Watch "NullPointerException occured" New topic
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: 19672
    
  18

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 - OCEEJBD 6
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