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};
int count=0;
hello.ranks(scores);
public void ranks(int[] ranks){
int[] ranks1=Arrays.sort(ranks);
outer:
for(int i =ranks1.length-1;i>=0;i--){
if(ranks[i]<0|| ranks[i]>100){
continue;
}
count++;
System.out.println("考试的前三名为:");
System.out.println(ranks1[i]);
if(count>3){
break outer;
}
}
}
}
public static void ranks(int[] ranks){ Arrays.sort(ranks); System.out.println("考试的前三名为:"); outer:for(int i=ranks.length-1,count=0; ;i--){ if(ranks[i]<0|| ranks[i]>100){ continue; } else { count++; } System.out.println(ranks[i]); if(count>=3){ break outer; } } }
改了下 ranks方法 正常了
括号的问题,你看下你的main方法的最后一个大括号在哪?
no one can help me?
public class HelloWorld{
//完成 main 方法
public static void main(String[] args) {
HelloWorld hello= new HelloWorld();
int[] scores={89,-23,64,91,119,52,73};
hello.ranks(scores);
}
public void ranks(int[] ranks){
int count=0;
Arrays.sort(ranks);
System.out.println("考试的前三名为:");
for(int i =ranks.length-1;i>=0;i--){
if(ranks[i]<0|| ranks[i]>100){
continue;
}
count++;
System.out.println(ranks[i]);
if(count>=3){
break;
}
}
}
}