Scanner s = new Scanner(System.in);
int choice = 0; if(s.hasNextInt())
{
choice = s.nextInt();
} s.close();//关闭scanner
05-11 17:29