猿问

求大神解答一下这个为啥显示num++;这行出错呀?谢谢0.0

import java.util.Arrays; 

public class HelloWorld

    public static void main(String[] args)

    {

    int[] scores={89,-23,64,91,119,52,73};

    System.out.println("本次考试的前三名为:");

    HelloWorld hello=new HelloWorld();

    hello.max3(scores);

    }

    public void max3(int[] scores)

    {

       Arrays.sort(scores);

       int num = 0;

       for(int i=scores.length-1;i>=0&&num<3;i--)

       {

          if(scores[i]<0||scores[i]>100);

          continue;

          num++;

          System.out.println(scores[i]);

       }

    }

}


慕粉3322918
浏览 1372回答 3
3回答

冰山点水

for循环里面if语句的条件后面的分号去掉。建议按标准格式写代码:if(条件){语句}

惟愿_无事常相见

你把for循环里面if语句后面的分号删掉试试。。
随时随地看视频慕课网APP

相关分类

Java
我要回答