This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Null Pointer Exception  RSS feed

 
Josh Ziegler
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having trouble getting some code to work, it gives me a run-time error. Any help is appreciated.
 
Jeff Langr
author
Ranch Hand
Posts: 799
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You never initialize tileList. That's one potential problem, although there may be others.
It would help next time if you (a) provided code that compiled and (b) provided the stack trace.
Also, as a matter of style, put your instance variables at the top of the class, prior to any methods or constructors.
-Jeff-
[ April 01, 2004: Message edited by: Jeff Langr ]
 
Josh Ziegler
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help. This code was being edited constantly before I posted it here so who knows what happened to the initialization of tileList. Hopefully thats it and not something more complex. Also this is a stupid question but how do you print a stack trace? Thanks again.
 
Jeff Langr
author
Ranch Hand
Posts: 799
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your program crashes, you should see the stack trace in the console; my intent was for you to copy and paste it into your posting.
If you trap an expected exception, you can print a stack trace using the printStackTrace method defined on Throwable.
-j-
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!