+ 1
What is for input of char in scanner cladd
find out
3 Answers
+ 15
char a=n.next().charAt(0);
Declare a Scanner name n or .. and use the above sentence.
+ 4
The Scanner Class does not have a method that returns a char. You could use nextLine() to get a String and convert it to a char or call toCharArray() on it to get a char array and then loop over the chars in the array.
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
char[] characters = sc.nextLine().toCharArray();
for(char character: characters) {
System.out.println(character);
}
}
}
+ 1
thanks friends for your support