Commentary below slide.
|
|
Slide 18 of 111
Notes:
The copy of the 'g' character that was echoed to the video console appears on the screen. The video console now shows the 'a' character followed by the 'g' character. The original 'g' character remains behind the 'a' character at the junction.
At this time, the CPU is still executing the ReadByte program below. The statement in the program the CPU is executing is still code = System.in.read(). So, the computer is still evaluating System.in.read(). The program is unaware that an 'a' key or a 'g' key was ever pressed.
public class ReadByte {
public static void main(String args[]) {
char ch;
int code;
try {
code = System.in.read();
} catch (Exception e) {
System.out.println("Error found.");
return;
}
ch = (char) code;
System.out.println("Read: " + ch);
}
}