日期:2014-05-20 浏览次数:20790 次
class Person { String name ="No name"; public Person(String nm) { name = nm; } } class Employee extends Person { String empID = "0000"; [color=#FF0000]public Employee(String id) { empID = id; }//这里有什么错误阿?[/color] } public class wren4255 { public static void main(String[] args) { Employee e = new Employee("4321"); System.out.println(e.empID); } }
class Person { String name ="No name"; public Person(String nm) { name = nm; } } class Employee extends Person { String empID = "0000"; public Employee(String id) { super(id); empID = id; } } public class wren4255 { public static void main(String[] args) { Employee e = new Employee("4321"); System.out.println(e.empID); } }
------解决方案--------------------
class Person { String name ="No name"; public Person(){}; public Person(String nm) { name = nm; } } class Employee extends Person { String empID = "0000"; public Employee(String id) { empID = id; } } public class wren4255 { public static void main(String[] args) { Employee e = new Employee("4321"); System.out.println(e.empID); } }
------解决方案--------------------
class Person { String name ="No name"; public Person(String nm) { name = nm; } } class Employee extends Person { String empID = "0000"; [color=#FF0000]public Employee(String id) { empID = id; [/color] }//这里有什么错误阿? [color=#FF0000]public Employee(String id) { super(id);empID = id; [/color] } public class wren4255 { public static void main(String[] args) { Employee e = new Employee("4321"); System.out.println(e.empID); } }