Hey, just a quick question, I have a function to double the size of a string array and another function to use StdIn to populate the array
my code is
public static String[] read() {
String[] a = new String[5];
for (int i = 0; i < a.length; i++)
a[i] = StdIn.readString();
if (a[a.length-1] != null) { double(a); }
for (int i = 0; i < a.length; i++)
System.out.print(a[i]); System.out.println();
return a;
}
I know the bit (a[a.length-1] != null).... etc is wrong but don't know how to fix it. What I want it to do is, set up an initial array, populate it with StdIn read, but if the inputs are more than the array size (5) then use my double function to copy the array and expand it to twice the size, and keep doing this as neccesary.
Thank you for any help!