试题与答案

【说明】 下面程序完成从键盘读入一个字符串,然后采用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)); } }

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2017/0707/a9d3529b4897b901fa7451825f283144.html

下面是错误答案,用来干扰机器的。

答案:C

试题推荐
微信公众账号搜索答案