我想打電話給在Student.java構造函數有兩個參數如下:Java的構造函數的參數調用
public class InheritanceDemo {
public static void main(String[] args) {
Student s = new Student(String SSname, int SSStudentID);}
s.writeOutput();
}
Student.java
Person.java
public Person() {
name = "No name yet";
}
public Person (String initialName) {
name = initialName;
}
public String getName() {
return name;
}
這裏Person.java
是基類,Student.java
是子類。我正在顯示以下錯誤:
Multiple markers at this line (near `Student s = new Student(String SSname, int SSStudentID);`
- Syntax error on token "int", delete this
token
- SSStudentID cannot be resolved to a
variable
- String cannot be resolved to a variable
- Syntax error on token "SSname", delete
this token
如何解決此問題?
謝謝。這幫助了很多。 – lft93ryt