I am reading input from a file (filename provided as command line argument) containing an unknown number of integers. The custom 'readInts' method will read the integers and return an array. I do not know about the size of the array to initialize it in the beginning.
The class containing the 'readInts' method- https://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/In.java.html
int []whitelist;
if(args.length>0) {
whitelist = In.readInts(args[0]);
}
Arrays.sort(whitelist);
How do I go about this, since the size of the array is unknown in the beginning? Will there be any memory loss if I create an array of size 'x' in the beginning, and then assign the output of readInts to it?