?java——无法从静态上下文中引用非静态变量

2019年2月16日11:20:22 发表评论 949 views
/**
 * Created by xabcd on 2019/2/16.
 */
public class total_jiekou
{
    interface A
    {
        int i = 10;
        public void sayI();
    }
    interface E
    {
        int x = 40;
        public void sayE();
    }
    interface B extends A,E{
        int j = 20;
        public void sayJ();
    }
    class C implements B {
        public void sayI()

        {
            System.out.println("i=" + i);
        }

        public void sayJ()

        {
            System.out.println("j=" + j);
        }

        public void sayE()

        {
            System.out.println("e=" + x);
        }
    }
    public static void main(String[] args)
    {
        C c = new C();//红色异常
        c.sayI();
        c.sayJ();
    }

}

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: