Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

static final variable in non-static Inner class  RSS feed

 
Prakash Rai
Ranch Hand
Posts: 107
Eclipse IDE MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


As we say that static declaration is not Allowed in Non-static Inner class . Then why static final variable is allowed?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the compiler can get rid of the variable and just replace all uses of it with the constant.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!