-3
这个循环的目的是在一个句点键输入后立即停止,但它不工作,我不明白为什么。为什么这个do-while循环不停止?
import java.io.IOException;
public class ControlFlowTest {
public static void main(String[] args) throws java.io.IOException {
char ch ;
do{
ch = (char) System.in.read();
}while(ch != '.');
}
试着检查'ch' cotains? –
https://ericlippert.com/2014/03/05/how-to-debug-small-programs/ –
[Works for me。](http://ideone.com/bu5wlT) – shmosel