title: How to take character input in java
body: <p>In C, we are able to take input as character with the keyword <code>char</code> from keyboard as </p>
  
  <p><code>scanf("%c", &amp;ch);</code></p>
  
  <p>But In Java how to do this?</p>
  
  <p>I have tried this:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Main {
    public static void main(String[] args) {
      Scanner scanner = new Scanner(System.in);
      System.out.println("Enter a character: ");
      char c = scanner.next().charAt(0);
      System.out.println("You have entered: "+c);
    }
  }
  </code></pre>