Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Char in scanner

// 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);
    }
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #Char #scanner
ADD COMMENT
Topic
Name
6+1 =