代碼哪里有問題
import java.util.Arrays;
public class HelloWorld {
? ??
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? ? ? HelloWorld hello=new HelloWorld();
? ? ? ? int[] scores={89,12,110,-89,56,80};
? ? ? ? hello.getScores(scores);
? ? }
? ??
? ??
? ? //定義方法完成成績排序并輸出前三名的功能
? ? public int getScores(int[] scores){
? ? ? ? int nums=0;
? ? ? ? Arrays.sort(scores);
? ? ? ? for(int i=scores.length-1;nums<3;i--){
? ? ? ? ? ?if(scores[i]>100||scores[i]<0)?
? ? ? ? ? ? ? ?continue;
? ? ? ? ? ? ? ?nums++;
? ? ? ? ?System.out.println("前三名的成績"+scores[i]);? ? ??
? ? ? ? ? ? ? ?
? ? ? ? ? ?
? ? ? ? ? ??
? ? ? ? ? ??
? ? ? ??
? ? ? ? }
??
? ? }
? ??
? ??
? ??
? ??
? ??
? ??
? ??
? ??
? ??
}
2018-09-04
首先你的方法中用的無返回值應(yīng)該是 void而不是int
其次,他讓你輸出前三名的成績,你輸出的是除負數(shù)之外的成績。
2018-09-04
有沒有大神啊