Do you mean like this, using Arrays.deepToString() to print nested arrays?
String string = "This is a string";
System.out.println(string);
String[] words = string.split(" ");
System.out.println(Arrays.toString(words));
String[][] wordsArray = new String[words.length][];
for (int i = 0; i < words.length; i++)
wordsArray[i] = new String[] { words[i] };
System.out.println(Arrays.deepToString(wordsArray));
Output
This is a string
[This, is, a, string]
[[This], [is], [a], [string]]
If you just want to build the string you listed, this is however an easier way:
String string = "This is a string";
StringJoiner joiner = new StringJoiner("], [", "[", "]");
for (String word : string.split(" "))
joiner.add(word);
System.out.println(joiner.toString());
Output
[This], [is], [a], [string]
Or same in a single statement using streams:
System.out.println(Pattern.compile(" ")
.splitAsStream("This is a string")
.collect(Collectors.joining("], [", "[", "]")));
Or you could just cheat and do this:
String string = "This is a string";
System.out.println("[" + string.replaceAll(" ", "], [") + "]");
wordintoarrayofchars|strings?toString()on an array looks like[Ljava.lang.String;@63947c6b. If you didSystem.out.println(Arrays.toString(wordsArray.split(" "));you'd be less confused.