我正在尝试使用以下switch
语句System.in.read()
:
char ch1, ch2;
ch1 = (char) System.in.read();
switch(ch1) {
case 'A':
System.out.println("This A is part of outer switch.");
ch2 = (char) System.in.read();
// ch2 = 'A';
switch(ch2) {
case 'A':
System.out.println("This A is part of inner switch");
break;
case 'B':
System.out.println("This B is part of inner switch");
break;
} // end of inner switch
break;
case 'B': // ...
ch2 = (char) System.in.read();
not 似乎被执行,除非明确声明ch2 = 'A'
,否则内部switch
语句将不会被执行。那么如何进行第二项read()
工作呢?