首先:这段代码能正确执行!
public class ReadIn {
public static void main(String[] args) throws Exception {
InputStream in=System.in;
StringBuilder sb=new StringBuilder();
while(true){
int ch=in.read(); //为什么此处能调用abstract read(),
if(ch=='\r')
continue;
if(ch=='\n'){
String s=sb.toString();
if("over".equals(s))
break;
System.out.println(s.toUpperCase());
sb.delete(0, sb.length());
}
else
sb.append((char)ch);
}
}
}

为什么此处能调InputStream的abstract read()
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- WorldMobile 2015-02-04 04:33关注
int ch=in.read(); //为什么此处能调用abstract read(),
很正常,为什么不能调用?
解决 无用评论 打赏 举报