I have a string as [Ian Wood P. M. Visscher]
[Ian Wood L. Mengersen]
[Ian Wood]
[P. M. Visscher Ian Wood].I want to write this string into two dimensional array. (i.e) String a[0][0]=Ian Wood ,a[0][1]=P. M. Visscher,a[1][0]=Ian Wood, a[1][1]=L. Mengersen and so on.Every time when I would give input, the names in the string will change.
How do I split it and store it in the above form in the array. Please suggest any idea . Thanks in advance.Following is the code I worked on,but does not split properly.
String[] parts = output.split(" ");
String[][] table = new String[parts.length / 2][2];
for (int i = 0, r = 0; r < table.length; r++) {
table[r][0] = parts[i++];
table[r][1] = parts[i++];
}
System.out.println(java.util.Arrays.deepToString(table));