我正在为UCSDStudent构造一个构造函数,并且我发现我的构造函数没有问题。 请指出一些具体问题,并帮助我做出自己的决议!实际和正式的参数列表长度不同
class UCSDStudent extends Base {
private String name;
private long Studentnum;
public UCSDStudent (String name, long number) {
UCSDStudent s = new UCSDStudent();
s.setName(name);
s.setStudentNum(number);
}
public void setName(String setName) {
name = setName;
}
public void setStudentNum(long setStudentNum){
Studentnum = setStudentNum;
}
public String getName() {
return this.name;
}
public long getStudentNum() {
return this.Studentnum;
}
....... // some more code, but I will put the instantiation in the main func.
// create Student and place in symbol table
if(!symtab.insert (
new UCSDStudent (buffer, number), 1)){
System.out.println("Couldn't insert " + "student!!!");
}
......
UCSDStudent stu = new UCSDStudent (buffer, 0);
这是基类。
public abstract class Base {
public String getName() { // identifier function
return null;
}
}
你可以请你的错误发布实际的堆栈跟踪? – mdewitt
我们应该告诉你问题吗?通常不是这样吗? –
那么问题是,你正在调用一个函数,要求提供不同数量的参数。但是由于这段代码没有显示任何有趣的内容,因此没有完整的错误信息,等等。我们真的帮不了你。 – Xarn