java吧 关注:1,233,185贴子:12,698,892
  • 4回复贴,共1

求java继承,改错

收藏回复

class Employee{
String name;
public Employee(String n){
name=n;
}
}
class Manager extends Employee{
String department;
Manage(String s,String d){
super(s);
department=d;
}
}
class TestManager{
public static void main(String[] args){
Manager m1=new Manager();
Manager m2=new Manager("ZhangFan","marker");
}
}


IP属地:安徽1楼2012-01-02 20:12回复
    TestManager类访问修饰符加public,Manager类无参构造已经没有了。。必须再写一个无参的


    2楼2012-01-02 20:29
    回复
      Manager类的构造方法写错了 Manager
      Maneger m1 = new Manager("ZhangFan") 需要加个参数
      有main方法的类 设为public


      3楼2012-01-02 23:23
      回复
        class Employee{
         String name;
         public Employee(String n){
          name=n;
         }
         public Employee(){
         }
        }
        好吧 其实我是来测试格式的


        IP属地:上海5楼2012-01-03 09:58
        回复