java replace substring in string specific index
<p>How would I replace a string <code>10100</code> with <code>10010</code> using the algorithm "replace the last substring 10 with 01."
I tried </p>

<pre><code>s=s.replace(s.substring(a,a+2), "01");
</code></pre>

<p>but this returns <code>01010</code>, replacing both the first and the second substring of <code>"10"</code>.
"a" represents s.lastindexOf("10");</p>
