how to increase an regular array length in java?
Arrays in Java are of fixed size that is specified when they are declared. To increase the size of the array you have to create a new array with a larger size and copy all of the old values into the new array.
ex:
//declare an array at first Object[] myStore= new Object[10];
//now if I almost use up all spaces of myStore, I can create a new one with double length myStore = Arrays.copyOf(myStore, myStore.length*2); //the original one will be garbage collected by jvm
浙公网安备 33010602011771号