ITPub博客

首页 > 应用开发 > > int count=hello.sort(scores);这里为什么要用scores,而不是scores[]?

int count=hello.sort(scores);这里为什么要用scores,而不是scores[]?

作者:touchfeeling 时间:2019-10-18 13:47:09 0 删除 编辑

import java.util.Arrays;

public class HelloWorld {

    public static void main(String[] args) {

HelloWorld hello = new HelloWorld();

int[] scores={79,52,98,81};

        

//调用方法,传入成绩数组,并获取成绩的个数

int count=hello.sort(scores);

        

System.out.println("共有"+count+"个成绩信息!");

}

    

/*

* 功能:将考试成绩排序并输出,返回成绩的个数

* 定义一个包含整型数组参数的方法,传入成绩数组

* 使用Arrays类对成绩数组进行排序并输出

* 方法执行后返回数组中元素的个数

*/

public int sort( int[]scores    ){

Arrays.sort(scores);

System.out.println(Arrays.toString(scores));

        //返回数组中元素的个数

        return scores.length;

}

}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1451/viewspace-3123504/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 关于PHP的问题
请登录后发表评论 登录
全部评论

注册时间:2019-04-15

  • 博文量
    105
  • 访问量
    1220