Shahiduzzaman Shahid Shahiduzzaman Shahid - 3 months ago 31
Java Question

How to take character input in java

In C, we are able to take input as character with the keyword

from keyboard as

scanf("%c", &ch);

But In Java how to do this?

I have tried this:

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(;
System.out.println("Enter a character: ");
char c =;
System.out.println("You have entered: "+c);


use the System class

char yourChar =