class Good{
void  f1(){
System.out.println("f1()");
}
void f1(int i){
System.out.println("f1(int i)");
}
void f1(double i){
System.out.println("f1(double i)");
}
}
class Good1 extends Good{
void  f1(){
System.out.println("导出类的f1()");
super.f1();
f1(1);
f1(1.4);
}


}
public class P713 { /**
 * @param args
 */
public static void main(String[] args) {
// TODO 自动生成方法存根
}
Good1 g=new Good1();
g.f1();
}帮小弟看下这个错在哪里 为什么g.f1();会出错

解决方案 »

  1.   

    把代码:
    Good1 g=new Good1(); 
    g.f1();
    放到main()方法里就好了;
    输出:
    导出类的f1()
    f1()
    f1(int i)
    f1(double i)
      

  2.   

    你把语句放在了方法的外面能不出错吗?将
    Good1 g=new Good1(); 
    g.f1();
    或者 
    g.f1();
    放到一个方法中或放到mian函数中
      

  3.   

    你单独运行Good1出错吗  super.f1(); 
    调用父类方法应该放在第一行吧  偶也是菜鸟 不知道对不对