阅读背景:

为什么编译器说接口中的公共静态字段是“最终的”,尽管它不是

来源:互联网 

Please see the below code --

请看下面的代码 -

public interface TestInterface {
    public static String NON_CONST_B = "" ; 
}

public class Implemented implements TestInterface {
    public static String NON_CONST_C = "" ;
}

public class AutoFinal  {

    public static String NON_CONST_A = "" ;

    public static void main(String args[]) {
        TestInterface.NON_CONST_B = "hello-b" ;
        Implemented.NON_CONST_C = "hello-c";
        AutoFinal.NON_CONST_A = "hello-a" ;
        Implemented obj = new Implemented();
    }
}
pu



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: