public class Test {
Father f1=new Son();
Father f2=new Son(); f1.getAge();
f2.getAge(60);
}
class Father{
String sex="man";
int age=50;
public String getSex() {
return sex;
}
public int getAge() {
System.out.println("父类的方法:");
return age;
}
}
class Son extends Father{
public int getAge() {
System.out.println("子类的方法:");
return age;
}
public int getAge(int age) {
this.age=age;
return age;
}
} 作者: 白磊 时间: 2013-5-5 22:03
尹桥印 发表于 2013-5-5 22:00
呃,你主函数是在什么地方
额 实在是太慌张了 还没有发现作者: 白磊 时间: 2013-5-5 22:07
白磊 发表于 2013-5-5 22:03
额 实在是太慌张了 还没有发现
主函数加在这里
public static void main(String[] args) {
Father f1=new Son();
Father f2=new Son();
f1.getAge();
f2.getAge(60);
}
这局还是出错 怎么回事啊 弄不明白作者: zms2100 时间: 2013-5-6 00:18
我只能说LZ的代码写的相当的乱糟糟,O(∩_∩)O~,不过新手都这样,我暂时也好不到哪去,O(∩_∩)O~。
说下问题: