System.out.print
果壳 2009-09-27 01:44:07 再一个问题,JDK源文件中的OutPutStream.java中的write方法有3个
1个是public abstract void write(int b) throws IOException;
2个是public void write(byte b[]) throws IOException {
write(b, 0, b.length);
}
3个是 public void write(byte b[], int off, int len) throws IOException {
if (b == null) {
throw new NullPointerException();
} else if ((off < 0) || (off > b.length) || (len < 0) ||
((off + len) > b.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return;
}
for (int i = 0 ; i < len ; i++) {
write(b[off + i]);
}
}
第2个和第3个write互相调用,我就没看出来到底想做什么,如果长度是对的不是就会一直反复调用死循环么,我想看下System.out.print的原理是什么,但是翻到过后看不明白,好像没实现什么功能的