public static void main(String[] args) {
/*==================复制======================*/
//克隆
int[] a = {1,2,3,4};
// int[] copyA = a.clone();
//
// int[] copyA = Arrays.copyOf(a, 4);
//
// int[] copyA = Arrays.copyOfRange(a, 1, 4);
//
// //a数组的0开始复制到copyA的1开始,复制长度3
// int[] copyA = new int[4];
// System.arraycopy(a, 0, copyA, 1, 3);
// System.out.println(Arrays.toString(copyA));
/*==================填充======================*/
Arrays.fill(a, 100);
System.out.println(Arrays.toString(a));
Arrays.fill(a, 1,3,99);
System.out.println(Arrays.toString(a));
}
java数组的复制与填充
最新推荐文章于 2024-05-02 05:45:00 发布