0
爲什麼我在嘗試返回對象數組時遇到第22行中的意外類型錯誤?在returing object數組中出現意想不到的typer錯誤
public class StudentDemo {
public static void main(String args[]){
StudentDemo program = new StudentDemo();
program.start();
}
public void start(){
Student one = new Student(1, "x", 80.0);
Student two = new Student(2, "y", 81.0);
Student three = new Student(3,"z", 79.5);
Student four = new Student(4, "a", 85.0);
Student five = new Student(5, "b", 86.0);
Student arr[] = {one,two,three,four,five};
Student[] splitarr = splitStudentArray(arr, char 'e'); //line 22
splitarr[0].getName();
}
public Student[] splitStudentArray(Student arr[], char choice){
Student[] splitArr = new Student[5];
if(choice == 'e'){
for(int i = 0; i<5; i++){
if(arr[i].getMarks()%2 == 0){
splitArr[i] = arr[i];
}
}
}
else if(choice == 'o'){
for(int i = 0; i<5; i++){
if(arr[i].getMarks()%2 != 0){
splitArr[i] = arr[i];
}
}
}
return splitArr;
}
}
錯誤說:
要求:價值發現:類。
請幫我找出錯誤及其發生的原因。
謝謝,真的沒有看到這麼小的一個錯誤。 – Himanshu