這題這樣寫哪里錯(cuò)了?
import java.util.Arrays;
public class HelloWorld {
? ??
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? ? ? HelloWorld hello=new HelloWorld();
? ? ? ? int[] scores={89,-23,64,91,119,52,73};
? ? ? ? hello.getScores(scores);
? ? }
? ??
? ? //定義方法完成成績(jī)排序并輸出前三名的功能
? ? public void getScores(int[] scores){
? ? ? ? Arrays.sort(scores);
? ? ? ? int[] newScores=new newScores[3];
? ? ? ? for(int i=scores.length-1,j=0; i>=0,j<=2; i--){
? ? ? ? ? ? if(scores[i]<0||scores[i]>100){
? ? ? ? ? ? ? ? continue;
? ? ? ? ? ? }
? ? ? ? ? ? newScores[j]=scores[i];
? ? ? ? ? ? j++;
? ? ? ? }
? ? ? ? System.out.println("考試成績(jī)的前三名為:"+Arrays.toString(newScores));
? ? }
? ??
? ??
}
2016-06-03
?? int[] newScores=new newScores[3];
應(yīng)該是:?int[] newScores=new int[3];
?i>=0,j<=2
條件不能用,應(yīng)該用&&