![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e124. Expanding an ArrayThe length of an array cannot be changed. The closest thing to expanding an array is to create a larger one of the same type and copy the contents from the old array.Object newArray = Array.newInstance(array.getClass().getComponentType(), Array.getLength(array)*2); System.arraycopy(array, 0, newArray, 0, Array.getLength(array));
e121. Getting the Length and Dimensions of an Array Object e122. Getting the Component Type of an Array Object e123. Creating an Array e125. Getting and Setting the Value of an Element in an Array Object
© 2002 Addison-Wesley. |