/* 例題2.4.35を while 文で書きなおした例. do-while 文を使えば,変数 input の初期化は不要だった.*/ import java.io.*; class Foo { public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); int answer = 34; int input = 0; // 1回目の条件判断が必ず偽になるように0で初期化 while (input != answer) { input = Integer.parseInt(br.readLine()); } } }