title: Big-O runtime of String Concatenation explained( Java )?
body: <p>If all the elements of the <code>words</code> array are all Strings of fixed length <code>x</code>,  </p>
  
  <pre><code>public String joinWords(String[] words) {
     String sentence = "";
     for (String w : words) {
          sentence = sentence + w; 
     }
     return sentence;
  }
  </code></pre>
  
  <p>Can someone explain to me how the runtime of this algorithm becomes <code>O(xn^2)</code> ? And how does <code>StringBuilder</code> or <code>StringBuffer</code> improve on this ?</p>