0

Can anyone tell me how to take input of a character and boolean type in java?

java

27th Sep 2018, 3:14 PM
Umar Khalid
Umar Khalid - avatar
3 Respuestas
0
char x = 'X'; char y = 'Y'; for char you can also use ASCII (Dec) https://www.rapidtables.com/code/text/ascii-table.html char x = 120; char y = 121; boolean isRight = false; boolean isRight = true;
27th Sep 2018, 3:37 PM
Daniel (kabura)
Daniel (kabura) - avatar
0
taking input from the user??
27th Sep 2018, 3:39 PM
Umar Khalid
Umar Khalid - avatar
0
you must use the scanner class char: the user gives String and then the first symbol is replaced by char Scanner scanner = new Scanner(System.in); char x = scanner.next().charAt(0); boolean: the user gives "true" or "false" Scanner scanner = new Scanner(System.in); boolean isTrue = scanner.nextBoolean();
27th Sep 2018, 3:44 PM
Daniel (kabura)
Daniel (kabura) - avatar