NEED HELP WITH JAVA PROBLEM!

willtriv

Member
Oct 21, 2005
149
0
0

the error thrown is

Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at Course.getPts(Course.java:38)
at GpaApplet.actionPerformed(GpaApplet.java:76)
at java.awt.Button.processActionEvent(Button.java:388)
at java.awt.Button.processEvent(Button.java:356)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)


for some reason when the getPts() method is called it thinks the class has no value stored. I've initiated the class as this...

courses[counter] = new Course( letterIn.getText() , Double.parseDouble( cHIn.getText() ) );

in the contructor the values seem to work correctly and seem to be storing the right values at the time.

when i call the getPts() it looks like this...
if(courses[counter].getPts()>0 && courses[counter].getCh()>0)

but it seems that the values that are stored in the constructor are gone!

any advice?
 

mundane

Diamond Member
Jun 7, 2002
5,603
8
81
Which line is 38? And are you sure you've initialized the grade and cH variables?
 

willtriv

Member
Oct 21, 2005
149
0
0
it seems that grade isn't instantiated. I cant under stand why. It must be my parsing from the applet.
Thanks
wt