• Post Reply Bookmark Topic Watch Topic
  • New Topic

another inner class question from K.Mughal.

 
Minhaj Mehmood
Ranch Hand
Posts: 400
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Anyone would like to put some light "why its printing "21" instead of "23" (without quotes off course)".


-Minhaj
 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dude because in you are creating a new object of Outer so innercounter will be set to 0 again which will be 1 when a new Inner object is created

i hope this time i am right....right Neha?
 
Neha Daga
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!