在 main 方法中读取一个包含 5 个整数值的数组。创建一个单独的函数,该函数将对数组进行排序并将数组返回给 main 方法并在那里打印。
到目前为止,我已经完成了:
import java.util.*;
public class arraysort {
public static void main(String[]args) {
Scanner in = new Scanner (System.in);
System.out.println("Enter 5 integers: ");
int [] x = new int [5];
for (int i=0; i<5; i++) {
x[i] = in.nextInt();
}
}
public static int sortarray(int [] value) {
int max = value[0];
for (int i = 1; i < value.length; i++) {
//I am not sure after this point
//I just did the rest
int [] y = new int [5];
Scanner in = new Scanner (System.in);
value[i] = in.nextInt();
Arrays.sort(y);
System.out.println(y);
}
}
}