在System类中有一段代码:
public final static InputStream in = nullInputStream();
public final static PrintStream out= nullPrintStream();
public final static PrintStream err= nullPrintStream();
请问nullInputStream()是什么意思啊?那位高手能具体解释一下吗?
public final static InputStream in = nullInputStream();
public final static PrintStream out= nullPrintStream();
public final static PrintStream err= nullPrintStream();
请问nullInputStream()是什么意思啊?那位高手能具体解释一下吗?
解决方案 »
- 怎么把 一个方法中的JTextField 局部变量传递到下一个方法进行修改 条件是:不用全局变量!!!
- 在网络编程中java与c++那个更有优势
- 多选:下列哪些方法与方法public void add(int a) {} 为合理的重载方法()
- 关于 static 方法的引用
- 如何设置table属性,使得它不会压缩设置好的列宽?
- 怎样将eclipse用NLpack1-eclipse-SDK-3.2.1-win32.zip汉化?
- jsp中关于include的中文乱码问题
- 程序疑问,请指教!
- 测试分
- 怎樣實現對Vector中的object排序?
- 求chm格式的中文api
- 如何用JAVA代码监听某个开放端口
private static InputStream nullInputStream() throws NullPointerException
方法的说明里已经告诉我们为什么这么写了,简单的说它要先被初始化成null,然后再由initializeSystemClass()
方法初始化。
好好研究一下下面这段英文
/** * 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(). */
/**
* 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().
*/
private static InputStream nullInputStream() throws NullPointerException {
if (currentTimeMillis() > 0) {
return null;
}
throw new NullPointerException();
} private static PrintStream nullPrintStream() throws NullPointerException {
if (currentTimeMillis() > 0) {
return null;
}
throw new NullPointerException();
}
这2个方法是要把in,out和err初始化为null