Replace sub string in a String in Java
Description
The following code shows how to replace sub string in a String.
Example
/*from www.j a va2 s .c o m*/
public class Main {
public static void main(String[] args) {
String str = "java2s.com is";
str = str.replace("i", "I");
System.out.println(str);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »