Core API
How do I replace characters in string?
package org.kodejava.lang; public class StringReplace { public static void main(String[] args) { String text = "The quick brown fox jumps over the lazy dog"; System.out.println("Before: " + text); // The replace method replace all occurrences of character // 'o' with 'u' and returns a new string object. text = text.replace('o', 'u'); System.out.println("After : " + […]
Artikel oleh Wayan · Sumber: Kode Java ↗
Terjemahan artikel ini belum tersedia. Isi asli ditampilkan.
package org.kodejava.lang;
public class StringReplace {
public static void main(String[] args) {
String text = "The quick brown fox jumps over the lazy dog";
System.out.println("Before: " + text);
// The replace method replace all occurrences of character
// 'o' with 'u' and returns a new string object.
text = text.replace('o', 'u');
System.out.println("After : " + text);
}
}
The result of the code snippet:
Before: The quick brown fox jumps over the lazy dog
After : The quick bruwn fux jumps uver the lazy dug
