請問,這個循環哪里有問題啊?
import java.util.Arrays;
public class HelloWorld {
??? //完成 main 方法
??? public static void main(String[] args) {
??? int []scores = {89,-23,64,91,119,52,73};
??? HelloWorld hello = new HelloWorld();
?????? ?
??????? System.out.println("考試成績前三名為");
??????? hello.b(scores);
??? }
?? ?
??? //定義方法完成成績排序并輸出前三名的功能
?? ?
?? ?
??? public void b(int[] c){
?????? ?
??????? Arrays.sort(c);
?????? ?
??? for (int i=c.length-1 ; i>c.length-4 && i<=length-1; i--){
??????????? System.out.println(c[i]);
?????? ?
??? }
??????
2019-05-23
后面b函數里面的for循環的判斷條件的i<=length-1應該是i<=c.length-1,但是,實際上都不需要這個條件