Replace Character in a String in Java
Description
The following code shows how to replace Character in a String.
Example
/*from w ww. j a va 2s . c om*/
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 »