大神来求解
import java.util.Arrays;
public class HelloWorld {
//完成 main 方法
public static void main(String[] args) {
int[] scores = {89, -23, 64, 91, 119, 52, 73};
HelloWorld hello = new HelloWorld();
int[] scoreRank = hello.rank(scores);
System.out.println(Arrays.toString(scoreRank));
}
//定义方法完成成绩排序并输出前三名的功能
public int[] rank(int[] scores) {
int[] scoreRank = new int[3];
Arrays.sort(scores);
int j = 0;
for (int i = scores.length - 1; i <= scores.lenght - 3; i--) {
scoreRank[j] = scores[i];
j++;
}
return scoreRank;
} //用来求数组scores中最大的三个数。for循环有点问题,可我看不出来,帮我看看!