In java: how to replace every instance of firsts character with second character
<p>Given a function which inputs a string and two chars, how can I create a method which removes every instance of the first char and replaces it with the second. Here is what I have so far ( I am writing this code using bluej):</p>

<p>*note the class will compile, but it does not produce the desired result.</p>

<pre><code>public class CharReplace
{
    public static String Replace( String str, char c1, char c2)
    {
        String result = "";


        for(int i = 0; i &lt; str.length(); i = i+1) // mechanism which allows us to read through the
        // string chracter by character
        {
            if(str.charAt(i) == c1){
                 c1 = c2;
                }

            result = result + str.charAt(i);
        }
        return result;
    }
}
</code></pre>

<p>I appreciate your input and suggestions. </p>

<p>Thanks, </p>
