Here you can find the source of getChar()
public static char getChar()
//package com.java2s; //License from project: Open Source License import java.util.Scanner; public class Main { private final static Scanner commandLine = new Scanner(System.in); public static char getChar() { char choice; String line = commandLine.nextLine().toLowerCase().trim(); if (line.length() == 0) { choice = ' '; } else//from w w w . ja va2 s . co m choice = line.charAt(0); return choice; } }