比如
String test1 = "111222333";
String test2 = "111";
要在test1里去处test2

解决方案 »

  1.   

    test1 = test1.replace(test2,"");
      

  2.   

    test1 = test1.replace(test2,"");
      

  3.   

    substring()方法里只有一个参数表示什么意思
      

  4.   

    substring()方法中的只有一个参数表明起始位置为0
      

  5.   

    substring()方法里只有一个参数表示什么意思=======================
    表示的是start的位置,结束位置默认为字符串的末尾
    而不是楼上一位老兄说的起始位置为0
      

  6.   

    看lang类中string 里有关字符操作函数
      

  7.   

    replace 只能替换单个字符。只有 jdk1.4 及 1.4 以上版本能够: replaceAll( test2, "" )
      

  8.   

    1.5支持替换CharSequence
    =============
    replace
    public String replace(CharSequence target,
                          CharSequence replacement)Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence. The replacement proceeds from the beginning of the string to the end, for example, replacing "aa" with "b" in the string "aaa" will result in "ba" rather than "ab". Parameters:
    target - The sequence of char values to be replaced
    replacement - The replacement sequence of char values 
    Returns:
    The resulting string 
    Throws: 
    NullPointerException - if target or replacement is null.
    Since: 
    1.5