liuhaozzu 2015-02-02 01:59 采纳率: 0%
浏览 1426

为什么此处能调InputStream的abstract read()

首先:这段代码能正确执行!
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);
}
}
}

  • 写回答

1条回答 默认 最新

  • WorldMobile 2015-02-04 04:33
    关注

    int ch=in.read(); //为什么此处能调用abstract read(),

    很正常,为什么不能调用?

    评论

报告相同问题?

悬赏问题

  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试