8-1編程老是報錯
import java.util.Arrays;
public class HelloWorld {
? ??
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? ? ? int scores[] = {89,-23,64,91,119,52,73};
? ? ? ? System.out.println("前三名成績?yōu)椋?);
? ? ? ? HelloWorld hello = new HelloWorld();
? ? ? ? hello.topthree(scores);
? ? ?
? ? ? ??
? ? ? ??
? ? }
? ??
? ? //定義方法完成成績排序并輸出前三名的功能
? ? public void topthree(int socres[]){
? ? ? ? Arrays.sort(scores);
? ? ? ? int count = 0;
? ? ? ? for(int i = scores.length-1;i>=0;i--){
? ? ? ? ? ? if(scores[i]>100 || socres[i]<0){
? ? ? ? ? ? ? ? continue;
? ? ? ? ? ? }
? ? ? ? ? ? count++;
? ? ? ? ? ? if(count>3) {break;}
? ? ? ? ? ? System.out.println(scores[i]);
? ? ? ? }
? ? ? ? ?
? ? }
}
? ? 我這哪里錯了啊
2018-11-25
老弟??scores? ?socres? 都拼錯了
2018-11-25
定義的數(shù)組是scores,可是下面的是socres。就是寫錯了。