Shahiduzzaman Shahid Shahiduzzaman Shahid - 1 year ago 119
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);

Answer Source

use the System class

char yourChar =
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download