java - Why cant I declare static final variable in non static block? -
package com.static2; public class static { final static int y; { y=8;// error: value cant initialized } }
we can access static members in non static block why cant access static final members in non static blocks?
an instance initializer block (which have in example) executed each instance of class, means final static
variable initialized multiple times (once each instance). that's not allowed final
variables.
Comments
Post a Comment