plusOut code java
<p>I'm trying to write a code that will give this output:</p>

<pre><code>plusOut("12xy34", "xy") → "++xy++"
</code></pre>

<p>it returns a string where the characters in the original have been replaced by + except for where the 2nd string appears in the first string, but im having problems with my code. Here it is:</p>

<pre><code>public String plusOut(String str, String word) {
  String newString = "";
  for (int i=0; i&lt;str.length()-1; i++) {
    if (str.substring(i, word.length()).equals(word)) {
      newString = newString + str.substring(i, word.length());
    }
    else {
      newString = newString + "+";
    }
  }
  return newString;
}
</code></pre>
