title: How is StringBuffer implementing append function without creating two objects?
body: <p>It was an interview question. I was asked to implement the <code>StringBuffer</code> append function. I saw the code after the interview. But I cannot understand how the operation is done with creation of a single object.</p>
  
  <p>I am thinking like this.</p>
  
  <pre><code>String s = "orange";
  s.append("apple");
  </code></pre>
  
  <p>Here two objects are created.</p>
  
  <p>But </p>
  
  <pre><code>StringBuilder s = new StringBuilder("Orange");
  s.append("apple");
  </code></pre>
  
  <p>Now here only one object is created.</p>
  
  <p>How is Java doing this operation?</p>