1.定义从键盘上得到一个字符的方法。
public static char getChar() throws IOException {
InputStream in = System.in;
return (char)in.read();
}
2.定义从键盘上得到一个字符串的方法。
/**
* 键盘输入的方法
*/
public static String getKey() {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = null;
try {
s = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return s;
}