I have this input in ArrayList<String> :
cat eats mouse mouse eats cheese cheese is tasty
(blank lines should be ignored, as I will read this input from a file)
and I want to convert it to a 2-dimensional array of String, which will have dimensions [no. of elements in ArrayList][3] [no. of elements in ArrayList][3] .
Not. 3 is fixed, that is, each sentence will have 3 words. eg:
"cat" "eats" "mouse" "mouse" "eats" "cheese" "cheese" "is" "tasty"
here is what i tried:
public static int processData(ArrayList<String> array) { String str[]=new String[array.size()]; array.toArray(str); String str1[][]=new String[str.length][5]; for(int i=0;i<str.length;i++) { str1[i][]=str.split("\\s+"); //i want to do something like this, but this is showing errors. } return 0; //this is temporary, I will be modifying it }
Tell me if I do not understand.
user3759895
source share