I have the same result.double c characters.
So curious,            String s = "a";
            String a = s.replaceAll("[a]","c");
            System.out.println(a);

解决方案 »

  1.   

    学学正则表达式,再用replaceAll
      

  2.   

    呵呵,java的字符串问题多着呢!!!比如说
    String a = "aaaa$aaaaa";
    String[]b = a.split("$");
    System.out.print(b.length);大家猜想,树出多少?
      

  3.   

    楼主,理解一下这个
      String s = "";
        String a = s.replaceAll("a*","c");
        System.out.println(a);打印出来的是 c 
    知道那个*号在这里做什么事的吧用 String a=s.replaceAll("a+","c");
    就可以得到正确结果了。
      

  4.   

    absolutely b.length = 1.
    Caze $ character binds the end of line.
    So the spilt method would find the end of line,then only return 1 and only one String array.
      

  5.   

    To kypfos(深圳不是我的家) :But why double c