Dynamic Array List size
arrays, dynamic, java
Solution
array size needs to be fixed while initialization, use `List` instead and then have array from `List` using `toArray()`
For example:
List<Integer> listOfInt = new ArrayList<Integer>(); //no fixed size mentioned
listOfInt .add(1);
listOfInt .add(2);
listOfInt .add(3);
//now convert it to array
Integer[] arrayOfInt = list.toArray(new Integer[listOfInt .size()]);
Problem
How can I set size of a dynamic array with Java? I tried `setsize(...)` with the array variable but not working. How can I do this?