Forums Register Login

Why does this crash

+Pie Number of slices to send: Send

i get a java.lang.nullpointerexception
+Pie Number of slices to send: Send
Please post the EXACT error message. It contains a LOT of information that can help us help you track down the problem.

Layne
+Pie Number of slices to send: Send


sry about that im new here
[ May 01, 2005: Message edited by: Jeffrey Chu ]
+Pie Number of slices to send: Send


Typo. Should be "word2 = ". Since word2 is null when you call add(), you get a NullPointerException. That stack trace says the error happens at line 28 in your applet; so you look at line 28, and figure out what's wrong.
[ May 01, 2005: Message edited by: Ernest Friedman-Hill ]
+Pie Number of slices to send: Send
No problem. Let's analyze what the error message says.

The first line indicates that your program threw an NullPointerException (which you obviously already knew). The next line starts what is called the "call stack". This is the chain of method calls that lead up to the exception. The first line tells you that this exception was thrown from java.awt.Container.addImpl() which is in the standard Java API. Notice that it also indicates the source file name and line number. If you want to, you can look at the source code that comes with the JDK. At this point, we probably just want to find the problem with your own code, so let's continue. The next line tells you that Container.addImpl() was called from Container.add() which is again a method from the Java API. The third line finally gives us a method in your own code: Pretty.init(). Container.add() was called on line 28 in Pretty.java. So now what is line 28?

Well, it looks like I took to long to finish typing my response. EFH has already given you some more information. However, I thought I'd still submit my post so that you can understand the information that the error message gives you and hopefully track down these kinds of errors on your own next time.

Keep Coding!

Layne
[ May 01, 2005: Message edited by: Layne Lund ]
+Pie Number of slices to send: Send
o wow... now i feel stupid... thanks guys for your input
Yeah, but does being a ninja come with a dental plan? And what about this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 720 times.
Similar Threads
Null pointer exception thrown in paintComponent
Determining width and height of a String
Trying to draw image, but not showing up
null pointer exception...
Displaying an image in a set location in an applet
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:07:46.