【说明】 下面程序完成从键盘读入一个字符串,然后采用parseInt方法将其转换为一
问题:
【说明】 下面程序完成从键盘读入一个字符串,然后采用parseInt方法将其转换为一个相应的整数。 import java.io.*; public class testThrows{ public static (1) readString() (2) IOException{ int ch; String r=""; boolean done=false; while( (3) ){ ch=System.in.read(); if(ch<0 || ch=0xd) //处理回车符中第一个符号 done=true; else r=r+(char)ch; } return r; } public static void main(Stling args[]){ String str; (4) { str=readString(); } (5) (IOException e){ System.out.println("error"); return; } System.out.println("input integer: "+Integer.parselnt(str)); } }