in(String[] args) { int[] scores={89,-23,64,91,119,52,73}; System.out.println("考试成绩前三名:"); HelloWorld hello=new HelloWorld();

来源:7-1 编程练习

Tien_jojo

2016-04-24 20:46


哪里错了啊

import java.until.Arrays;

public class HelloWorld {

    

    //完成 main 方法

    public static void main(String[] args) {

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

        System.out.println("考试成绩前三名:");

        HelloWorld hello=new HelloWorld();

        hello.showTop3(scores);//存入成绩数组

        Arrays.sort(scores);//数组排序

       

       }

    

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

    public void showTop3 (int scores){

         

        int num=0;

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

        {

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

            {

                continue;

            }

            num++;

            if(num>3)

            {

                break;

            }

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

        }

        

    }

}


写回答 关注

1回答

  • zhuan3169359
    2016-04-24 21:02:29

    第一行"until"改为"util”;

    你把排序放在调用方法之后是错的,这样在自定义方法中的数组并没有排序;

    Tien_j...

    System.out.print("Thank you!")

    2016-04-27 22:55:51

    共 1 条回复 >

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

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

1166278 学习 · 17590 问题

查看课程

相似问题