/**
* @author lautturi.com
* Java example:Replaces a character at a specific position in a string
*/
import java.util.*;
public class Lautturi {
public static void main(String[] args) {
//Orlautturinal String
String str = "Hallo java.";
// character to replace
char ch = 'e';
// replaced index
int index = 1;
// replace string
str = str.substring(0, index) + ch + str.substring(index + 1);
System.out.println(str);
}
}Sourcew:ww.lautturi.comoutput:
Hello java.