我有一个测试文件,根据它我需要构建我的程序测试文件 下面。但是,我困惑于s1.showDetails(System.out);我从来没有遇到过 参数System.out任何人都可以帮助。该怎么办?当我试图编写showDetails()时,编译器写入错误。我的学生代码是在这之下谢谢你提前!System.out参数
import java.util.*;
public class Q2 {
public static void main(String [] args)
{
// Start on section A
System.out.println("Question 2");
System.out.println("Start on part A");
Student s1 = new Student("John", "Smith", 42);
s1.showDetails(System.out);
Course cs = new Course("Computer science");
}
}
public class Student {
private String name;
private String familyName;
private int moduleMark;
private int total;
protected Student(String name, String familyName, int moduleMark)
{
this.name = name;
this.familyName = familyName;
this.moduleMark = moduleMark;
}
public String getName()
{
return name;
}
public String getFamilyName()
{
return familyName;
}
public int getModuleMark()
{
return moduleMark;
}
public String showDetails()
{
return (this.name + " " + this.familyName + " " + moduleMark + total);
//print(name);
}
}
您需要发布你所得到的错误。另外,如果这是作业,那么添加'作业'标记 – 2012-01-03 21:58:37
线程“main”中的异常java.lang.Error:未解决的编译问题: \t Student类型的showDetails()方法不适用于参数(PrintStream) \t at Q2.main(Q2.java:9) – 2012-01-03 21:59:44
这不是作业 – 2012-01-03 22:00:18