java arrays在哪个包_//导入Java中util类中的Arrays工具包

线上365bet注册 admin 2025-12-05 07:28:23

源自:7-1 编程练习

//导入Java中util类中的Arrays工具包

//导入Java中util类中的Arrays工具包

import java.util.Arrays;

//创建一个HelloWorld类

public class HelloWorld {

//导入一个 main 方法

public static void main(String[] args) {

//创建一个对象:hello

HelloWorld hello = new HelloWorld();

//定义数组变量并赋值

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

//调用方法并传入成绩信息

hello.sort(scores);

//输出"考试成绩的前三名为:"

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

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

public int sort(int[] scores){

Arrays.sort(scores);

int num=0;

int nuy=0

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

if( scores[i]>100){

coutiune;

}

num++;

if(num>3){

break;

}

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

}

}

}

提问者:weixin_二个工人_0

2018-03-20 21:31