我有一個測試文件,根據它我需要構建我的程序測試文件 下面。但是,我困惑於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