[java] Java dynamic array sizes?

I recommend using vectors instead. Very easy to use and has many predefined methods for implementation.

import java.util.*;

Vector<Integer> v=new Vector<Integer>(5,2);

to add an element simply use:

v.addElement(int);

In the (5,2) the first 5 is the initial size of the vector. If you exceed the initial size,the vector will grow by 2 places. If it exceeds again, then it will again increase by 2 places and so on.