这样是最优的解决办法吗
import java.util.Arrays;
public class HelloWorld {
public static void main(String[] args) {
HelloWorld hello=new HelloWorld();
int[] scores={89,-23,64,91,119,52,73};//将成绩放入数组中
hello.sorts(scores);
}
public void sorts (int []scores) {
int count=0;
Arrays.sort(scores);//对成绩进行排序
for ( int i = scores.length - 1; i >= 0; i-- ) {
if(scores[i]<0||scores[i]>100) {
continue;
}else {
System.out.println("成绩的前三名分别为:"+scores[i]);
count++;
}
if(count==3) {
break;
}
}
}
}