interface Ikk
{
public static final int aa=3;
public void hh();
}public class dd implements Ikk
{
public void hh()
{
System.out.println("interface"); }
public static void main(String args[])
{
hh();
}
}

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【sure2003】截止到2008-07-04 16:10:38的历史汇总数据(不包括此帖):
    发帖的总数量:198                      发帖的总分数:9077                     
    结贴的总数量:196                      结贴的总分数:9017                     
    无满意结贴数:2                        无满意结贴分:50                       
    未结的帖子数:2                        未结的总分数:60                       
    结贴的百分比:98.99 %               结分的百分比:99.34 %                  
    无满意结贴率:1.02  %               无满意结分率:0.55  %                  
    值得尊敬
      

  2.   

    hh方法不是静态方法,不能那样调用。
    new dd().hh();
    就可以了。
      

  3.   


        public static void main(String args[])
        {
            new DD().hh();
        }
      

  4.   

    main 方法是静态方法,里面只能引用类中的静态方法,非静态方法得实例化后才能访问。把 hh(); 改成 new Test3().hh(); 这样就行了。静态方法在 JVM 启动时就在内存区中有固定的地址了,因此是可以直接访问的。
    但是非静态方法,在类中存放的只是一个内存的偏移地址,得实例化后决定了对象
    的引用地址再加上这个偏移地址就可以直接访问了。
      

  5.   

    刚开始学,强烈建议严格按照编码规范来
    public class DD implements Ikk
    {
        public void hh()
        {
            System.out.println("interface");    }    public static void main(String args[])
        {
            new DD().hh();
        }
    }interface Ikk
    {
        public static final int AA = 3;    public void hh();
    }
      

  6.   

    Cannot make a static reference to the non-static method hh() from the type ddinterface Ikk
    {
        public static final int aa=3;
        public void hh();
    }public class dd implements Ikk
    {
        public void hh()
        {
            System.out.println("interface");    }
        public static void main(String args[])
        {
           new dd().hh();
        }
    }
      

  7.   

    public static void main(String args[])
    是静态方法,在静态方法中引用非静态方法或者变量是不允许的,将hh方法定义成静态就ok了