Cant set an array value equal to another array value?
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:
String a = scanner.next();
String split = a.split(",")
String string = split;
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.
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.
Re: Cant set an array value equal to another array value?
If you don't know how many lines or words per line there will be, try using an ArrayList. You might consider creating a class that represents a table (columns and rows). Java has something similar to this already (see DefaultTableModel (Java Platform SE 6) )