This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointerException

 
Abhimanyu Rathore
Ranch Hand
Posts: 32
Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys ..
This is my 1st post on Ranch(if you see any mistake please let me know)
This program is compiled fine.. but while running, its throwing an exception
Let me know if i am doing anything wrong

Program


Exception

 
Sudipta Laha
Ranch Hand
Posts: 49
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While creating the Thread you are creating a instance of the ClassA, so the instance of classB is not initialized as we are not calling the go method. For this you are getting the NullPointerException.
 
Abhimanyu Rathore
Ranch Hand
Posts: 32
Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sudipta Laha wrote:While creating the Thread you are creating a instance of the ClassA, so the instance of classB is not initialized as we are not calling the go method. For this you are getting the NullPointerException.


Yup! .. that's it..
Thanks a Lot Sudipta.. i appreciate!!..
 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... and welcome to the Ranch
 
Abhimanyu Rathore
Ranch Hand
Posts: 32
Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:... and welcome to the Ranch

Thanks Campbell
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic