You will need a String[]
of some size that you can determine dynamically.
Then, assign values to the array elements.
String[] anArray;
// some magic logic
anArray = new String[100];
for(int i = 0; i < anArray.length; i++){
// more magic logic to initialize the elements
}
Another option is a Vector<>
or ArrayList<>
like so:
List<String> anExpandableArray = new ArrayList<String>();
// add String data
anExpandaleArray.add("Foo");
anExpandaleArray.add("Bar");