是hellonulllove这是因为 + 这个运算符就是这样实现的,没有什么为什么

解决方案 »

  1.   

    试试:
         String a=new String();
         System.out.println("hello" + a + "!");
      

  2.   

    试试:
      String a=new String();  
      out.print("hello"+a+"love");
      

  3.   

    强制转换。楼上的空字符串。out.println(a.equals(""));
      

  4.   

    String a=new String();
         System.out.println("hello" + a + "!");   这样好象不行,我试过,要报错!
      

  5.   

    java中很多时候会强制调用toString()方法,如int i;out.print("hello"+i);
      

  6.   

    a要声明为static才能出现hellonulllove
      

  7.   

    a不需要声明为static就能出现hellonulllove
      

  8.   

    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");