你的replaceAll方法,我好像没有看到过!

解决方案 »

  1.   

    编译都不可能通过,String根本就没有 replaceAll()方法,应为replace,不过参数是字符而不是字符串
      

  2.   

    String strSource="IceTiger=Ice+Tiger";
    char first='=';
    char last='$';
    strRource.replace(first,last);
      

  3.   

    你的方法错误,String没有这个方法,它只有replace,意思就是新的替换所有的旧的。
    而且替换的也不是字符串,而是字符char
    另外你的strRource写错了,应该是strSource
    真难以想像居然可以编译……太奇怪了
    所以你的要改为
        String strSource="IceTiger=Ice+Tiger";
        char first='=';
        char last='$';
        strSource = strSource.replace(first,last); 
    如果你想要替换字符串的话,比如将"str"替换为"fdq",可以对应执行3遍以上操作就是,如果替换字符串的长度不同,则这样肯定是不行的。只能一个一个处理了。
      

  4.   

    在Java SDK2 1.4里面就有这个方法,因为是新的方法,所以不怎么会用!
      

  5.   

    以下是从1.4的技术文档中拷出来的。只是看不明白!
    replaceAll
    public String replaceAll(String regex,
                             String replacement)
    Replaces each substring of this string that matches the given regular expression with the given replacement. 
    An invocation of this method of the form str.replaceAll(regex, repl) yields exactly the same result as the expression Pattern.compile(regex).matcher(str).replaceAll(repl)Parameters:
    regex - the regular expression to which this string is to be matched 
    Returns:
    The resulting String 
    Throws: 
    PatternSyntaxException - if the regular expression's syntax is invalid 
    NullPointerException - if regex is null
    Since:
    1.4 
    See Also:
    Pattern
      

  6.   

    replaceAll(...) need a regular expression as the first parameter. try this:
    String first="\u003D";