額,一點也不知道哪里錯了。求大神幫忙
import java.util.Arrays;
public class HelloWorld {
? ??
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? ? ? HelloWorld hello=new HelloWorld();
? ? ? ? hello.print();
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
? ? }
? ??
? ? //定義方法完成成績排序并輸出前三名的功能
? ? public void print(){
? ? ? ? int[] ?Scores={89,-23,64,91,119,52,73};
? ? ? ? Arrays.sort(Scores);
? ? ? ? int num=0;
? ? ? ? for(int i=Scores.length;i>0;i--){
? ? ? ? ? ? if(Scores[i]>=0&&Scores[i]<=100){
? ? ? ? ? ? ? ? System.out.println(Scores[i]);
? ? ? ? ? ? ? ? num++;
? ? ? ? ? ? ? ? if(num>3)
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ??
? ? ? ? ? ? }
? ? ? ? ??
? ? ? ? ? ? ?
? ? ? ? ? ??
? ?
? ? ? ??
? ? ? ? }
? ? }
? ??
? ??
? ??
? ??
? ??
? ??
? ??
? ??
? ??
}
2015-09-28
應(yīng)該是length-1啊,你寫成length肯定會發(fā)生數(shù)組下標(biāo)越界異常的。
2015-10-02
if(num>=3)