Skip to content

Instantly share code, notes, and snippets.

@TheKojuEffect
Created September 26, 2013 14:56
Show Gist options
  • Save TheKojuEffect/6715379 to your computer and use it in GitHub Desktop.
Save TheKojuEffect/6715379 to your computer and use it in GitHub Desktop.
Convert String array to 2D char array.
public class StringToChar {
public static void main(String[] args) {
String[] strArr = { "HELLO", "WORLD" };
char[][] char2D = new char[strArr.length][];
for (int i = 0; i < strArr.length; i++) {
char2D[i] = strArr[i].toCharArray();
}
for (char[] char1D : char2D) {
for (char c : char1D)
System.out.print(c + " ");
System.out.println();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment