System类中的类字段对象定义:
> public final static InputStream in = nullInputStream();
打开InputStream类原码,read()为抽象方法;
> public abstract int read() throws IOException;
可在程序中,经常这么用:
char c;
c = (char)System.in.read();都是抽象方法,没有方法体的怎么回事。。

解决方案 »

  1.   

    InputStream 只是 System.in 的类型描述, 是个接口. 它采用了很多native手段, 去看一下 Java本地接口 吧.
      

  2.   

    我也一直没弄理解SYSTEM.IN是怎么回事。
      

  3.   

    想象一下,System.in.readLine()它是要去读键盘输入, 但是jvm运行在操作系统之上, 那么它没有权利直接去读取io硬件, 而且操作系统有windows, lunux, mac等等, 他们的io的实现方式又有差异, 这个只有通过native手段把当前jvm运行之上的操作系统的io映射给System里面的in, in只是一个接口, 用来handle这种实现的最终结果.
      

  4.   

    System.in.readLine()它是要去读键盘输入
      

  5.   

    你查查 nullInputStream(); 这个函数是怎么实现的
      

  6.   

    其实这里更有意思的问题是,先把in和out这些final的变量都初始化为空,然后用native方法改变其值。
      

  7.   

    Java API 中是这样描述in的:
    in
    public static final InputStream in
    The "standard" input stream. This stream is already open and ready to supply input data. Typically this stream corresponds to keyboard input or another input source specified by the host environment or user. 
      

  8.   

    问题是这public abstract int read() throws IOException; 
    没有被重写!!!!!!!!!!