• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Run Time error

 
Abeer El-shaer
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[color=darkred] [/color]



the ERROR IS IN RUN TIME

Exception in thread "main" java.lang.NullPointerException
at java.awt.Container.addImpl(Container.java:1039)
at java.awt.Container.add(Container.java:363)
at Adition1.<init>(Adition1.java:29)
at Adition1.main(Adition1.java:43)
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple of suggestsions:

1. Don't use a lot of color. It makes your post hard to read. You tried to make the whole thing dark red. Fortunately, you didn't use the tags right, so it didn't work.

2. Put only one statement on a line. This is bad:


3. Don't name variables the same as methods. Calling add(add) is confusing. Variable names should be nouns (things) or at least noun-ish. Method names should be verbs (actions).

If the line 29 it's complaining about matches the line 29 in the code you posted, then it's the one I mentioned in my point #2 above. Since the error is occurring inside Container.add(), and not on line 29 directly, we know that c is not null. So either resultt (also a confusing name) must be null or the "add" variable must be null. Possibly both.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12143
30
Chrome Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will also find that you get much more help here if you actually ask a question. Simply posting 45 lines of code and an error you got turns a lot of folks off. It looks like you don't feel it important enough to spend the time to formulate a real question, so many folks will not find it important enough to compose a reply.
 
Ivan Franko
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at line 29:


Variable resultt - what is this?
 
Abeer El-shaer
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ivan Franko wrote:Take a look at line 29:


Variable resultt - what is this?

it's a JTextField variable!!
 
Henry Wong
author
Marshal
Pie
Posts: 21190
80
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aroma Karim wrote:
Ivan Franko wrote:Take a look at line 29:


Variable resultt - what is this?

it's a JTextField variable!!



And is the JTextField variable actually pointing to a JTextField object??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic