This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NullPointerException" Watch "NullPointerException" New topic
Author

NullPointerException

Abhimanyu Rathore
Ranch Hand

Joined: Jan 23, 2010
Posts: 32

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

Joined: Aug 23, 2010
Posts: 49
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.


Regards,
Sudipta Kumar Laha
Abhimanyu Rathore
Ranch Hand

Joined: Jan 23, 2010
Posts: 32

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

Joined: Oct 13, 2005
Posts: 37926
    
  22
... and welcome to the Ranch
Abhimanyu Rathore
Ranch Hand

Joined: Jan 23, 2010
Posts: 32

Campbell Ritchie wrote:... and welcome to the Ranch

Thanks Campbell
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: NullPointerException
 
Similar Threads
why this causing error
Scope and classes/methods
Why runtime exception thrown is this code
do something when other frame close