编译器显示语法没错,就是运行不了
package com.text2;
import java.util.Arrays;
public class HelloWorld {
public static void main(String[] args) {
// TODO Auto-generated method stub
HelloWorld hello=new HelloWorld();
int [] scores={89,-23,64,91,119,52,73};
int [] nums=new int [3];
nums=hello.topThree(scores);
System.out.println("考试成绩的前三名为:");
for(int i=0;i<3;i++){
System.out.println(nums[i]);
}
}
public int [] topThree(int [] scores){
Arrays.sort(scores);
int [] nums=new int [3];
int i=0;
for(int j=scores.length-1;j>=0;j--){
if(scores[j]<0||scores[j]>100){
continue;
}
nums[i]=scores[j];
i++;
if(i>3)
break;
}
return nums;
}
}