public static void main(String[] args) {
// a、c、u、b、e、p、f、z
String[] arr = new String[]{"a","c","u","b","e","p","f","z"};
System.out.println(Arrays.toString(arr));
Arrays.sort(arr);
System.out.println(Arrays.toString(arr));
String[] arr2 = new String[9];
System.arraycopy(arr, 0, arr2, 0, 6);
arr2[6] = "m";
System.arraycopy(arr,6, arr2, 7, 2);
System.out.println(Arrays.toString(arr2));
}
public class HwNo02 {
public static void main(String[] args) {
String[] somemum = new String[] { "a", "c", "u", "b", "e", "p", "z",
"f" }; // 原数组为 8 个元素
int i = 0;//
System.out.print("原数组为: ");
for (i = 0; i < somemum.length; i++) {
System.out.print(somemum[i] + " ");// 遍历打印原数组
}
System.out.print("\n" + "升序后为: ");
Arrays.sort(somemum);
for (i = 0; i < somemum.length; i++) {// 遍历打印升序数组
System.out.print(somemum[i] + " ");
}
somemum.add(6,"M");add(int index, E element)
将指定的元素插入此列表中的指定位置
导包就不说了 ArrayList这个包 不知道用不用导 我忘了 你最好下载一个API看看方法 里面都能查到
pphkbdyd 5 2 f к· ㏄ lzym
lvvulg
aiwx
vhbvksw
sqyq
aqc