This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Threads  RSS feed

 
Vinu Menon
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one tell me why i am getting null pointer exception in the below program




Thanks
Vinay.
 
Omar Al Kababji
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because in your case the variable (a) is for the first instance. however when you do


new Thread(new B()).start()

a new object of type B will be created and its instance vaiable (a) is still null. so you either have to initialize your (a) variable in the constructor of class B, or do that line of code like this
 
Stephen Davies
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, check your references.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!