• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why does this crash

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i get a java.lang.nullpointerexception
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post the EXACT error message. It contains a LOT of information that can help us help you track down the problem.

Layne
 
Jeffrey Chu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


sry about that im new here
[ May 01, 2005: Message edited by: Jeffrey Chu ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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 ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Jeffrey Chu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
o wow... now i feel stupid... thanks guys for your input
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic