向个位高手请教一个很简单的问题, String a=null; out.print("hello"+a+"love"); 能输出什么结果,为什么?小弟感激不进! 是hellonulllove这是因为 + 这个运算符就是这样实现的,没有什么为什么 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 试试: String a=new String(); System.out.println("hello" + a + "!"); 试试: String a=new String(); out.print("hello"+a+"love"); 强制转换。楼上的空字符串。out.println(a.equals("")); String a=new String(); System.out.println("hello" + a + "!"); 这样好象不行,我试过,要报错! java中很多时候会强制调用toString()方法,如int i;out.print("hello"+i); a要声明为static才能出现hellonulllove a不需要声明为static就能出现hellonulllove 1.a不需要声明成static;2.a初始化的时候为null,即"";在java里,String类型值为null或者"",系统都默认为null;3.String a=null; System.out.print("hello"+a+"love"); 打印结果为 hellonulllove 特别注意:out.print("hello"+a+"love"); 应该为System.out.print("hello"+a+"love"); 对byte[] 二进制操作 date类的编写 java 运行异常 如何将网络文件读入char[]??? 关于String类中Split的问题。 数据库设计中的一个问题,讨论一下 得到系统目录!!! 求一个简单的能同时实现类,方法,实例,属性的例子 怎样异步执行存储过程 关于mina数据奇怪问题 j2se 和 j2ee 可以在同一个机器上安装么,之间有什么影响么? 谢谢 用FlowLayout可以控制add的component的大小(size)吗?
String a=new String();
System.out.println("hello" + a + "!");
String a=new String();
out.print("hello"+a+"love");
System.out.println("hello" + a + "!"); 这样好象不行,我试过,要报错!
2.a初始化的时候为null,即"";在java里,String类型值为null或者"",系统都默认为null;
3.String a=null;
System.out.print("hello"+a+"love");
打印结果为 hellonulllove
特别注意:out.print("hello"+a+"love"); 应该为System.out.print("hello"+a+"love");