I am new to java and I barely have the time to study it. Actually, my question is a little bit awkward and meaningless. I am trying to get letters from user input. I know that there are more efficient ways to do it, but I only want to know what is wrong with this method. The problem is when I write a string that doesn't contain any space the program is fine but if I write one with spaces it stops work.
Scanner qx = new Scanner(System.in);
String a = qx.next();
for(int b = 0; b<a.length();b++){
char z = a.charAt(b);
System.out.print(z + " ");
}
For example: When I wrote "Hi there"
(without quotes)
I expect the output of "H i t h e r e"
But it only shows "H i "
İf I would have written "Hithere"
it would show "H i t h e r e "
So why is there a difference between the one has spaces and the one doesn't?
Also, I am sorry for my grammar. I tried to do my best but I haven't practised for a long time.