title: How to dynamically replace string in java?
body: <p>I am trying use String.replace(oldChar,newChar) , but this returns a Changed string.
   Example: </p>
  
  <pre><code>String tempString= "abc is very easy";
  String replacedString=tempString.replace("very","not");
  System.out.println("replacedString is "+replacedString);
  System.out.println("tempString is "+tempString);
  </code></pre>
  
  <p>OUTPUT :</p>
  
  <pre><code>replacedString is abc is not easy
  tempString is abc is very easy
  </code></pre>
  
  <p>So my question is there any way to replace string without storing it in another String.</p>
  
  <p>I want output of </p>
  
  <pre><code>String tempString= "abc is very easy";
  tempString.replace("very","not");
  System.out.println("tempString is "+tempString);
  </code></pre>
  
  <p>as </p>
  
  <pre><code>tempString is abc is not easy.
  </code></pre>
  
  <p>by using replace function.</p>