public static void main(String[] args){
final StringBuffer a=new StringBuffer("hello");
final StringBuffer b=new StringBuffer("world");
a.append(b);
    System.out.println(a);

    final   String   c   =   new   String("hello");   
    final   String   d= new String ("world");
c.concat(d);     
    System.out.println(c);   
 
}

解决方案 »

  1.   

    helloworld 
    helloc.concat(d) 没有返回给任何对象,所以等于没有。
      

  2.   

    呵呵,这个题目真是会者不难,如果没搞清楚String类的方法,还真拿不准,必须走代码才可以
      

  3.   

    不错的tip
    楼主有心阿
      

  4.   

    http://cache.baidu.com/c?word=string%3B%2E%3Bconcat&url=http%3A//livedocs%2Eadobe%2Ecom/flash/9%2E0%5Fcn/main/00002160%2Ehtml&p=c6769a44d5934eab5bacd3684551cd&user=baidu
    1楼 你给解释一下  为什么这里就是 hello world
      

  5.   

    public   static   void   main(String[]   args){ 
    final   StringBuffer   a=new   StringBuffer("hello"); 
    final   StringBuffer   b=new   StringBuffer("world"); 
    a=a.append(b); 
            System.out.println(a);         final       String       c       =       new       String("hello");       
            final       String       d=   new   String   ("world"); 
    c.concat(d);           
            System.out.println(c);       
      
    }
    这样呢. 
      

  6.   

    public       static       void       main(String[]       args){   
    final       StringBuffer       a=new       StringBuffer("hello");   
    final       StringBuffer       b=new       StringBuffer("world");   
     a.append(b);   
                    System.out.println(a);                   final     String               c               =               new               String("hello");               
                    final      String               d=       new       String       ("world");   
    c=c.concat(d);                       
                    System.out.println(c);               
        

    再这样呢
      

  7.   

    a=a.append(b);   

     a.append(b);   
    没有任何区别
      

  8.   

    楼上的,final 指a 不能指向另一个对象哦!
     这里的代码并没有改变a引用的对象啊!!
      

  9.   

    final只是不能改变对象的引用。
      

  10.   

    其实很好理解
    String是不能更改的所以当c.concat(d);的时候,c作为一个String是不可能变成concat以后的String的
    从而没有变化
      

  11.   

    第一个输出:
    helloworld
    hello
    第二个和第三个有错误 :
    关键字final表示这个变量只能被赋值一次,一旦被赋值之后,就不能再更改了。
    所以我觉得这两句: 
    a=a.append(b); 
    c=c.concat(d);
    不能通过编译。