請問,這個(gè)循環(huán)哪里有問題啊?
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函數(shù)里面的for循環(huán)的判斷條件的i<=length-1應(yīng)該是i<=c.length-1,但是,實(shí)際上都不需要這個(gè)條件