public  interface  test {
  public static int a=1;
}
class   Test   implements   test{ 
   public static void main(String[] args) {  
      Test   t   =   new   Test();   
      System.out.println(t.a);
}   
}

解决方案 »

  1.   

    警告:the static field should be accessed in a static way
    请问是什么原因???
      

  2.   

    因为public   static   int   a=1;是静态的,而静态的是属于这个类的,所有这个类的实例对象是共享这样的属性的;不是属于某个特定的对象的,所以一般建议对这样的属性、方法进行访问的是时候通过类方式进行,如:
    System.out.println(Test.a);
    而你上面出现的也只是一个警告而不是错误,所以你也可以忽略不计。
      

  3.   

    interface 中不是只能定义常量吗,那样应该会有错误吧