import java.util.Arrays;
public class HelloWorld {
public void num(int[] nums){
System.out.println("考试成绩的前三名为");
Arrays.sort(nums);
int a = 1;
for(int i=(nums.length-1);i>=0;i--){
if(nums[i]<0||nums[i]>100){
continue;
}
System.out.println(nums[i]);
a++;
if(a>3)
break;
}
public static void main(String[] args) {
int[] scores={89,-23,64,91,119,52,73};
HelloWorld hello=new HelloWorld();
hello.num(scores);
}
}
首先你a的内循环就不对了,不是输出前三的成绩
还发现少个括号=-=