+ 1
How can I scan a character in java?
4 Respuestas
+ 1
Scanner sc = new Scanner(System.in);
char myChar = sc.next().charAt(0);
System.out.println(myChar);
+ 3
import java.util.Scanner;
//in main method create an object of Scanner
Scanner sc = new Scanner(System.in);
//Read input and assign it to a variable of type
String str = sc.nextLine();
//or
int i = sc.nextInt();
System.out.print(str);
+ 1
Anhjje 🐿 thank you 😊
0
I mean one character not string
char x;
How can I make the user enter the value of this x