我對Java很陌生,對於獲取設置數組感到困惑。只是超級基本的代碼,我想更新學生類中的成績數組。我使用double []輸入數組設置Graddes,但是當我調用getGrades時,它返回垃圾:[[email protected]
。設置並獲取雙精度數組
我知道這東西超級簡單的我失蹤
public class Student
{
private double[] grades;
public void setGrades(double[] grades)
{
this.grades = grades;
}
public double[] getGrades()
{
return grades;
}
public static void main(String[] args)
{
double[] input = {87.54, 67.45};
Student ted = new Student();
ted.setGrades(input);
System.out.println(ted.getGrades());
}
}
明白了,謝謝你們! –
不用理會@ dan_jen1 –