求大神解答,感激不尽
public class Java8_1 {
public static void main(String[]args){
System.out.println("前3名成绩为");
Java8_1 hello=new Java8_1();
hello.getscores(scores);//还有括号里的参数为什么不能写成scores[i];
}
public void getscores(int[] scores){
int[] scores={89,-23,64,91,119,52,73};//为什么定义数组放在这里就出错了啊?难道一定要开头就定义吗?
Arrays.sort(scores);
int nums=0;
for (int i=scores.length-1;i>0;i--){
if (scores[i]<=0||scores[i]>100){continue;
}nums++;
if (nums>3){
break;
}
System.out.println(scores[i]);
}
}
}