介面常量值可被修改

瓜瓜東西發表於2014-05-20
package com.wanju.project001.zonghe.test;


public class TestInterface implements MM {
    public static int a = 6;


    public static void main(String[] args) {
        MM mm = new TestInterface();
        System.out.println(a);
        System.out.println(TestInterface.a);
        System.out.println(mm.a);
    }
}


interface MM {
    int a = 5;

}


package com.wanju.project001.zonghe.test;


import com.sun.accessibility.internal.resources.accessibility;


public class TestAbstractClass extends NN {


    public static int a = 6;
    public static void main(String[] args) {
        NN test = new TestAbstractClass();
        System.out.println(a);
        System.out.println(TestAbstractClass.a);
        System.out.println(test.a);
    }
}


abstract class NN
{
    public static int a = 5;
}


相關文章