• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NullPointerException

 
Ranch Hand
Posts: 32
Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 49
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!..
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
... and welcome to the Ranch
 
Abhimanyu Rathore
Ranch Hand
Posts: 32
Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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


Thanks Campbell
 
reply
    Bookmark Topic Watch Topic
  • New Topic