There is a String “Saya”
I want to delete 4th character so it will be “Say”
I already do this
String word = "Saya";
char c = word.charAt(3);
String delete = Character.toString(c);
String newWord = word.replace(delete,"");
System.out.println(newWord);
But the result is “Sy”. It delete all character that same with 4th
Does anyone can help me?
You want to use substring(). Like so:
Make sure you check the length of your original string otherwise you may get an IndexOutOfBoundsException