One-dimensional array expansion

The array length is immutable, but the array is full

Capacity:
Create a new large-capacity array and copy the data from the small-capacity array into the large-capacity array. Array expansion efficiency is low, as little as possible to copy the array, in the array to create objects, it is best to estimate accuratelyCopy the code

Code:

Public class ArrayTest08 {public static void main(String[] args) {// arrayCopy // arrayCopy (5 arguments); Int [] SRC = {1, 11, 22, 3, 4}; Int [] dest = new int[20]; Arraycopy (SRC, 1, dest, 3, 2); arrayCopy (SRC, 1, dest, 3); For (int I = 0; i < dest.length; i++){ System.out.println(dest[i]); // 0 0 0 11 22 0... /* system.arrayCopy (SRC,0,dest,0,src.length); for (int i = 0; i < dest.length; i++) { System.out.println(dest[i]); String[] STRS = {"hello", "world!" , "study", "java", "oracle", "mysql", "jdbc"}; String[] newStrs = new String[20]; System.arraycopy(strs,0, newStrs, 0,strs.length); for (int i = 0; i < newStrs.length; i++){ System.out.println(newStrs[i]); } System.out.println("==============================="); Object[] objs = {new Object(), new Object(), new Object()}; Object[] newObjs = new Object[10]; System.arraycopy(objs, 0, newObjs,0,objs.length); for (int i = 0; i < newObjs.length; i++){ System.out.println(newObjs[i]); }}}Copy the code