下面的那些程序片段可能导致错误()
     
 a。String s = "Gone with the Wind";  String standard = s.toUpperCase();
 b. String s = "Gone with the wind";  String t;         t = s[3]+"one" ;
     c. String s = "home directory";  String t = s-"directory";
 d. String s = "Gone with the wind"; String t = "good";  String k = s + t ;

解决方案 »

  1.   

    a.没什么错的
    b,没有初始化String对象,空指针错
    c."-”错,没这种运算
    d.之所没错,经过“+”,引用k指向了一个新的字符串,并不是真正修改了原字符串
       要想真改,用StringBuffer
      

  2.   

     b    c   
    b   如果是 字符不超过三个则a[3] 是错误的 
    c   字符串中没有 -  这个写法
      

  3.   

    S[3]?java String有这用法么?