参考答案里inputcommand为啥要加上console= new Scanner(System.in),不加输入字符就死循环了
private static int inputCommand(){
int command;
try {
command = console.nextInt();
return command;
} catch (Exception e) {
//若输入字符型或者字符串,则抛出异常,捕获该异常,抛出”错误命令异常“
console = new Scanner(System.in);
//返回-1
return -1;
}
}