This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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 Java 8 in Action this week in the Java 8 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: 19552
    
  16

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NullPointerException occured
 
Similar Threads
FlowLayout manager wont work
can not find methods
cant find method from JOptionPane class
cant retrieve string from JTextField
[SOLVED] must implement the inherited abstract method