write down the syntax to input a character through scanner class with an example
Answers
Answered by
46
// Java program to read character using Scanner
// class
import java.util.Scanner;
public class ScannerDemo1
{
public static void main(String[] args)
{
// Declare the object and initialize with
// predefined standard input object
Scanner sc = new Scanner(System.in);
// Character input
char c = sc.next().charAt(0);
// Print the read value
System.out.println("c = "+c);
}
}
Hope this helps you. :)
Feel free to mark as brainliest.
:)
Answered by
2
Answer:
char<variable name>=<Scanner Object>.next().charAt(0);
Similar questions