append() is nice if you don't know beforehand how many elements you need to put in the array, as it grows the array each time you need to add an element there.
It is nice for newbies which don't need to be submerged by concept of ArrayList to be converted to array later, for example.
But it is very costly, because on each append, a new array is created with one more element than the previous one, and the old array is copied there!
To make your code work with append, which adds always at the end of the array (ie. after the empty elements you created first!), you can use the following code instead:
Code:int numElements = 10;
String[] fileNames = new String[0];
for (int i = 0; i<numElements; i++) {
String fileName = "Element " + i;
fileNames = append(fileNames,fileName);
}
print(fileNames[0]);
(simplified for testing)
Otherwise, if you know in advance the final size of the array, do as polymonkey shown.