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