To convert
String
to String
array in Java, do this: string.split("")
.Here's how you do it:
String string = "Hello World!";
String[] characters = string.split("");
// [H, e, l, l, o, , W, o, r, l, d, !]
System.out.println(java.util.Arrays.toString(characters));
String to a one-element array containing this String
If you actually meant putting a String
into an array, then here's how you do it:
String string = "Hello World!";
String[] stringInArray = new String[] { string };
// [Hello World!]
System.out.println(java.util.Arrays.toString(stringInArray));