Doesn't matter if they come from the scanner or from hard coded input. The split works as anticipated:
PHP Code:
Scanner s = new Scanner(System.in);
String a = s.nextLine();
String[] b = a.split(" ");
System.out.println("Chars in a:");
char[] ca = a.toCharArray();
for (Character c : ca)
{
System.out.println((int)c);
}
System.out.println("Chars in position 0:");
char[] c0 = b[0].toCharArray();
for (Character c : c0)
{
System.out.println((int)c);
}
System.out.println("Chars in position 1:");
char[] c1 = b[1].toCharArray();
for (Character c : c1)
{
System.out.println((int)c);
}
Terminal:
Code:
some phrase
Chars in a:
115
111
109
101
32
112
104
114
97
115
101
Chars in position 0:
115
111
109
101
Chars in position 1:
112
104
114
97
115
101