请问System.in是什么具体类型的变量?到底在何处定义的?
在System.java里,in是这样定义的:
public final static InputStream in = nullInputStream(); 
private static InputStream nullInputStream() throws NullPointerException

   if (currentTimeMillis() > 0)   
     return null;   
     throw new NullPointerException(); 
} 所以in似乎被赋了null值,这是怎么回事啊?

解决方案 »

  1.   

    io是阻塞式的,阻塞定义自己google一下
      

  2.   

    1. 定义地址在:java.lang.System,这个包是java本身自动引入的,所以你从来不用操心
    2. 至于类型,你已经知道了不是么?InputStream
    3. 关于初值为null的,你要看看注释就好了/**
    * The following two methods exist because in, out, and err must be
    * initialized to null. The compiler, however, cannot be permitted to inline
    * access to them, since they are later set to more sensible values by
    * initializeSystemClass().
    */如下两个方法存在的原因,是因为in, out和err流必须被初始化为空. 尽管编译器不能允许通过内联来访问它们,但是稍后它们会被initializeSystemClass()智能赋值.