I made a Scanner look into a text file (in the text file anything in it would be formatted: string,string,string....). Then, i made a while loop:
while(scanner.hasNext()){ String a = scanner.next(); String[] split = a.split(",") String string = split[0]; System.out.println(string); }
That works fine, but if i were to make the string 'string' an array, and set the first value the same as the first value in split, it would not work...
My goal is to split the lines in a text file by a comma, then pass each of those values into their own separate array.
example:
the text files reads: tree,butter,cow,milk
assuming this is the first line, i want 'tree' to be the first value in one array, 'butter' to be the first value of another array and so on.