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

Popular posts from this blog

php - trouble displaying mysqli database results in correct order -

depending on nth recurrence of job in control M -

sql server - Cannot query correctly (MSSQL - PHP - JSON) -