日期:2014-05-20 浏览次数:20642 次
public void input(){ int command; while(true){ try { command = System.in.read(); if(command==1){ break; } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
public void input(){ int command; while(true){ try { command = System.in.read(); if((char)command=='1'){//注意这行 break; } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
------解决方案--------------------
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();