How do I replace a letter in a string without .replace In Java -


i need finishing code. i'm trying go through every letter in word , changing lettertoreplace replacingletter. problem can't use .replace

please help

public string replaceletter(string word, char lettertoreplace, char replacingletter) {     string ans = "";     for(int = 0; < word.length(); i++)     {         char current = word.charat(i);         if(current == lettertoreplace)         {            lettertoreplace = replacingletter;         }         ans += character.tostring(word.charat(i));     }     return ans; } 

you're there. need update , print current:

if(current == lettertoreplace) {    current = replacingletter; } ans += character.tostring(current); 

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -