怎么错了,报错郁闷啊

来源:7-1 编程练习

1316478248

2015-01-13 13:08

error: unreachable statement
num ++;
^
1 error

写回答 关注

2回答

  • 伊兮尘昔
    2015-01-13 13:29:18
    已采纳

    continue之后能跟语句吗?

    131647...

    恩,知道错哪里了,感谢!

    2015-01-14 09:20:13

    共 1 条回复 >

  • _Exception
    2015-01-13 16:38:31

    public class HelloWorld {

        // 完成 main 方法

        public static void main(String[] args) {

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

            HelloWorld hello = new HelloWorld();

            hello.scoresSort(scores);

        }

        // 定义方法完成成绩排序并输出前三名的功能

        public void scoresSort(int[] scores) {

            Arrays.sort(scores);

            int num = 0;

            for (int i = scores.length - 1; i >= 0; i--) {

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

                    num++;

                    continue;

                }

                if (num > 3) {

                    break;

                }

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

            }

        }

    }


    131647...

    哦,注意到了,感谢!

    2015-01-14 09:19:37

    共 1 条回复 >

Java入门第一季(IDEA工具)升级版

0基础萌新入门第一课,从Java环境搭建、工具使用、基础语法开始

1167019 学习 · 17593 问题

查看课程

相似问题