不知道為什么,一直有錯
import java.util.Arrays;
public class HelloWorld {
? ??
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? ? ?int[] acores = {29,-23,64,91,119,52,73};?
? ? ? ?System.out.println("考試前三:");
? ? ? ?HelloWorld hellow = new HelloWorld();
? ? ? ?hellow.showTOP3(acoress);
? ? }
? ? //定義方法完成成績排序并輸出前三名的功能
? ? public void showTOP3(int[] acoress){
? ? ? ? Arrays.sort(acoress);
? ? ? ? int num= 0;
? ? ? ? for (int i = acoress.length - 1;i>=0;i--){
? ? ? ? ? ? if(acoress[i]<0 || acoress[i]>100) {
? ? ? ? ? ? ? ? continue;
? ? ? ? ? ? }
? ? ? ? ? ? num++;
? ? ? ? ? ? if(num>3){
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
? ? ? ? ? ? System.out.println(acoress[i]);
? ? ? ? }
? ? }
}
2019-06-18
第五行應(yīng)該是int[]acoress,你數(shù)組名打錯了。