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

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic