在java中,是否可以将字符指定为true或false语句?

时间:2014-04-20 13:35:10

标签: java variables

System.out.println("Enter Y/N for yes or no respectively if you wish for these features");                                    
System.out.print("Central vacuum: ");
check1 = sc.nextBoolean();

如果Y = true且N = false,是否可以使它

1 个答案:

答案 0 :(得分:3)

不,这是不可能的。

但是,您只需通过char阅读Scanner,并将其与预期输入('Y''N')进行比较。使用ifswitch

非常简单
相关问题