A little confused by this tiny program...
This is the program:
Code:
public class EchoText
{
public static void main(String[] args) throws java.io.IOException
{
System.out.println("Please enter some text and press Enter!");
int ch;
while ((ch = System.in.read()) != 13)
System.out.print((char) ch);
System.out.println();
}
}
The part that confuses me is in the while loop...
basically, i tye in "a"
then "b" it waits till I hit enter... then prints out "ab"
how come "ch" is not getting overwritten on every keypress?
I mean how come it does not only print out the last character (in this case it woud be "b")
I dont see any concatenation above...