public Student (String first, String last, Address home, Address school,String test1, int tests1,String test2, int tests2,String test3, int tests3) 你的构造函数是这样的,你就要传递相同个数的参数,并且类型要匹配! Student Baker = new Student ("Jane", "Baker", BHome, school); 你这样只有四个参数,当然不匹配,有错误了!
厉害,竟然会写java程序了,却不会编译,使用!!
TO zhutouzip(Speak out!-shyboy) 如何把String test1, int tests1,String test2, int tests2,String test3, int tests3这几个参数,做成既可传,也可不用传。
重载,你可以再定义一个 public Student (String first, String last) 只传两个参数。
javac StudentBody.java
java StudentBody
java StudentBody
我一执行javac StudentBody.java
就出错
运行:java StudentBody
javac Student.java
javac StudentBody.javajava StudentBody
这句时,出错了,说少传了参数。
怎么样使,后面的参数,不用传也行啊。
Address school,String test1, int tests1,String test2, int tests2,String test3, int tests3)
你的构造函数是这样的,你就要传递相同个数的参数,并且类型要匹配!
Student Baker = new Student ("Jane", "Baker", BHome, school);
你这样只有四个参数,当然不匹配,有错误了!
如何把String test1, int tests1,String test2, int tests2,String test3, int tests3这几个参数,做成既可传,也可不用传。
public Student (String first, String last)
只传两个参数。