aspose file tools
The moose likes Java in General and the fly likes static final variable in non-static Inner class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "static final variable in non-static Inner class" Watch "static final variable in non-static Inner class" New topic
Author

static final variable in non-static Inner class

Prakash Rai
Ranch Hand

Joined: Jan 10, 2011
Posts: 101



As we say that static declaration is not Allowed in Non-static Inner class . Then why static final variable is allowed?
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 5855
    
    6

Because the compiler can get rid of the variable and just replace all uses of it with the constant.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: static final variable in non-static Inner class
 
Similar Threads
Double-standard for inner class if it is non-static vs if it is static
Inner Class
Static variables in inner class not allowed why?
static modifier doubt
final local variable question