![]() |
The Java Developers Almanac 1.4 |
|
e75. Replacing Characters in a StringSince strings are immutable, thereplace() method creates a new string
with the replaced characters.
// Replace all occurrences of 'a' with 'o'
String newString = string.replace('a', 'o');
e71. Comparing Strings e72. Determining If a String Contains a Substring e73. Getting a Substring from a String e74. Searching a String for a Character or a Substring e76. Replacing Substrings in a String e77. Converting a String to Upper or Lower Case e78. Converting a Primitive Type Value to a String e79. Converting Between Unicode and UTF-8 e80. Determining a Character's Unicode Block e81. Determining If a String Is a Legal Java Identifier
© 2002 Addison-Wesley. |