/[classpath]/classpath/java/lang/String.java
ViewVC logotype

Diff of /classpath/java/lang/String.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.73 by twisti, Wed Nov 2 10:23:01 2005 UTC revision 1.74 by abalkiss, Mon Nov 7 18:04:32 2005 UTC
# Line 1873  public final class String implements Ser Line 1873  public final class String implements Ser
1873    
1874      return value;      return value;
1875    }    }
1876      
1877      /**
1878       * Returns true iff this String contains the sequence of Characters
1879       * described in s.
1880       * @param s the CharSequence
1881       * @return true iff this String contains s
1882       */
1883      public boolean contains (CharSequence s)
1884      {
1885        return this.indexOf(s.toString()) != -1;
1886      }
1887      
1888      /**
1889       * Returns a string that is this string with all instances of the sequence
1890       * represented by <code>target</code> replaced by the sequence in
1891       * <code>replacement</code>.
1892       * @param target the sequence to be replaced
1893       * @param replacement the sequence used as the replacement
1894       * @return the string constructed as above
1895       */
1896      public String replace (CharSequence target, CharSequence replacement)
1897      {
1898        String result = this;
1899        int pos = result.indexOf(target.toString());
1900        while (pos != -1)
1901          {
1902            result = result.substring(0, pos) + replacement.toString()
1903                     + result.substring(pos + target.length(), result.length());
1904            pos = result.indexOf(target.toString());
1905          }
1906        return result;
1907      }
1908  }  }

Legend:
Removed from v.1.73  
changed lines
  Added in v.1.74

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26