使用扫描仪从控制台读取布尔值
import java.util.Scanner; public class BooleanInputOutput { /*来 自 N o w J a v a . c o m*/ public static void main(String cLA[]) { Scanner myInput = new Scanner(System.in); boolean myBool = myInput.nextBoolean(); // true or false System.out.printf("%b\n", myBool); } }