How do i read a file and determine the # of array elements without having to look at the text file itself?
String temp = fileScan.toString();
String[] tokens = temp.split("[\n]+");
// numArrayElements = ?
The proper expression is tokens.length. So, you can assign numArrayElements like this:
int numArrayElements = tokens.length;
This counts the number of elements in the tokens array. You can count the number of elements in any array in the same way.
length does not "count" the number of elements in the array. Rather, it returns the array size which was stored in the array header when the array object was created (and which cannot have changed since).
tokens.length?length.