• Post Reply Bookmark Topic Watch Topic
  • New Topic

getter method gives null despite the value being set by Inner class method  RSS feed

 
Monica Shiralkar
Ranch Hand
Posts: 922
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to set the setter method of Outer class using the method of inner class. However on accessing it I get null.

Here are my classes:



Here is the class where value is being set:



However running the code gives a null pointer exception when run despite the value being set by the inner class method.

thanks
 
Stephan van Hulst
Saloon Keeper
Posts: 7975
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course, because you're calling checkValue() on a new outer object.
 
Monica Shiralkar
Ranch Hand
Posts: 922
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have found the mistake and it is resolved. I removed the line of code where second object was being created. Below code works fine.thanks





and Xyz.java

 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!