這個是什么原因啊
package imooc;
import java.util.Arrays;
public class yui {
public static void main(String[] args) {
int[] scores={89,-23,64,91,119,52,73};
yui hello =new yui();
? ? hello.getTop(scores);
? ? System.out.println("前三名的成績?yōu)椋?); ??
? ?}
? ?//定義方法完成成績排序并輸出前三名的功能
? ?public void getTop(int[] scores) {
? ?int num=0;
? ?Arrays.sort(scores);
? ?for(int i=scores.length;i>=0;i--){
? ? ? ?if(scores[i]<0||scores[i]>100){
? ? ? ? ? ?continue;
? ? ? ?}
? ? ? ?num++;
? ? ? ?if(num>3){
? ? ? ? break;
? ? ? ?}
? ? ? ?System.out.println(scores[i]);
? ?}
? ?}
}
2016-11-04
import java.util.Arrays;
public class yui {
public static void main(String[] args) {
int[] scores={89,-23,64,91,119,52,73};
yui hello =new yui();
? ?
? ? System.out.println("前三名的成績?yōu)椋?);
? ? hello.getTop(scores);
? ?}
? ?//定義方法完成成績排序并輸出前三名的功能
? ?public void getTop(int[] scores) {
? ?int num=0;
? ?Arrays.sort(scores);
? ?for(int i=scores.length-1;i>=0;i--){
? ? ? ?if(scores[i]<0||scores[i]>100){
? ? ? ? ? ?continue;
? ? ? ?}
? ? ? ?num++;
? ? ? ?if(num>3){
? ? ? ? break;
? ? ? ?}
? ? ? ?System.out.println(scores[i]);
? ?}
? ?}
}
2016-11-04
再把第7、8行的代碼上下位置換一下就行了
2016-11-04
i=scores.lenth-1