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();
Is is possible to make it that if Y = true and N = false?
NO, it is not possible.
But you can simply read a char
by the Scanner
, and compare it against expected inputs ( 'Y'
, 'N'
). Easy enough with an if
or switch
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.