System类中的类字段对象定义:
> public final static InputStream in = nullInputStream();
打开InputStream类原码,read()为抽象方法;
> public abstract int read() throws IOException;
可在程序中,经常这么用:
char c;
c = (char)System.in.read();
都是抽象方法,没有方法体的。。。怎么回事。。
...全文
15816打赏收藏
关于System.in的困扰。。。。
System类中的类字段对象定义: > public final static InputStream in = nullInputStream(); 打开InputStream类原码,read()为抽象方法; > public abstract int read() throws IOException; 可在程序中,经常这么用: char c; c = (char)System.in.read(); 都是抽象方法,没有方法体的。。。怎么回事。。
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.