我看了jdk6中System.java的源码,这么定义我们经常用的out:
public final static PrintStream out = nullPrintStream();
然后nullPrintStream()方法如下
private static PrintStream nullPrintStream() throws NullPointerException {
if (currentTimeMillis() > 0) {
return null;
}
throw new NullPointerException();
}整个方法跑完不是回复null就是抛Exception,那我们平时还怎么用的System.out.println(..)之类的方法?
public final static PrintStream out = nullPrintStream();
然后nullPrintStream()方法如下
private static PrintStream nullPrintStream() throws NullPointerException {
if (currentTimeMillis() > 0) {
return null;
}
throw new NullPointerException();
}整个方法跑完不是回复null就是抛Exception,那我们平时还怎么用的System.out.println(..)之类的方法?
http://topic.csdn.net/t/20050921/21/4285473.html
看了c/c++代码,还得去看汇编的底层代码,机器码,cpu电路·····
/**
* 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().
*/