0
Can anyone tell me how to take input of a character and boolean type in java?
java
3 odpowiedzi
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;
0
taking input from the user??
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();