I was solving some beginner Java examples and there is a question for which I have to return a new string where the character at index n
has been removed.
For example:
missingChar("kitten", 1) → "ktten"
I have to remove the first char in the String.
I tried this but it didn't work:
for (int i=0;i<str.length()-1;i++){
while (i==n){
str=str.replaceFirst(String.valueOf(str.charAt(i)),"");
return str;
}
}
Can someone tell me what is wrong with my code?