当我想要编译下面的代码编译时错误说:构造函数 Person(字符串,int) 是未定义的,等等...人员 p = 新人(“阿比”,2/4/2019);我写了这段代码:import java.util.Date;class Person{ String name; Date DOB; public Person(String name, Date dOB) { this.name = name; DOB = dOB; } public String getName() { return name; } public Date getDOB() { return DOB; }}class Student extends Person{ int StudentID; public Student(String name, Date dOB, int studentID) { super(name, dOB); StudentID = studentID; } public int getStudentID() { return StudentID; } public static void main(String[] args) { Person p = new Person("abhi",2/4/2019); // i can't pass date values to constructor student s = new Student("mark",2019-04-01,123456); //i can't pass date values to constructor System.out.println("Name "+p.getName()); System.out.println("DOB "+p.getDOB()); System.out.println("Name "+s.getName()); System.out.println("DOB "+s.getDOB()); System.out.println("StudID "+s.getStudentID()); }}`
添加回答
举报
0/150
提交
取消