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

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -