java array expansion

There are times when using an array instead of the stack, stuff array capacity is not enough capacity is needed

then:

 

1.Array.toString (); print directly traversing the array

2. The use of an array expansion Array.copyOf (), direct implementation of an array expansion feature, very powerful
 
(In fact, since after the array can not be changed once an example of its size, it is necessary to create a larger array, and the contents of the old array into a new array)
May be used expandCapacity () method to make the size of the array is doubled.

Guess you like

Origin www.cnblogs.com/xww115/p/11145157.html