public static void main(String[] args) {
char[] ch=null;
System.out.println(ch);
System.out .println("ch: "+ch);
}
为什么System.out .println("ch: "+ch);会输出ch: null
而System.out.println(ch);会报出空指针异常,其它类型的数组都不会发生这种情况,只有char[]会这样。
char[] ch=null;
System.out.println(ch);
System.out .println("ch: "+ch);
}
为什么System.out .println("ch: "+ch);会输出ch: null
而System.out.println(ch);会报出空指针异常,其它类型的数组都不会发生这种情况,只有char[]会这样。
解决方案 »
- 进来帮看看啊 谢咯
- JDialog在linux下无法显示标题?[
- 有没有点日历上的某一天就能弹出个页面的。。。。。。
- 谁能帮帮我,考试呀,不知道java applet和application程序的四步调试,哪位老大知道,快给个回复啊,谢谢了先
- 求救!JTable加载的单元格在点击之后消失...
- 一个很菜鸟的问题
- 如何用“按钮”提前结束一个循环
- 请问高手,我在java applet中有 密钥 ,如何不给客户端用反编译或其他方法知道我的密钥??
- 有什么办法自动在客户端安装jre1.3.1?
- JFreeChart 柱状图和折线图放在一起,只有左边的轴,怎样做?
- 大家给个意见,好意见就加分!
- 请教达人byte数据类型,如何正确赋值
write(cbuf, 0, cbuf.length);
}
cbuf.length 能不异常吗?
所以一个有异常,一个没异常 private void write(char buf[]) {
try {
synchronized (this) {
ensureOpen();
textOut.write(buf);
textOut.flushBuffer();
charOut.flushBuffer();
if (autoFlush) {
for (int i = 0; i < buf.length; i++)
if (buf[i] == '\n')
out.flush();
}
}
}
catch (InterruptedIOException x) {
Thread.currentThread().interrupt();
}
catch (IOException x) {
trouble = true;
}
}