title: Java list set method
body: <p>Okay, I have had a question, my code has seemed to work, but I have not tested it particuarly well. </p>
  
  <p>I'm trying to set an element in an ArrayList.</p>
  
  <pre><code>ArrayList&lt;StringBuilder&gt; g=new ArrayList&lt;StringBuilder&gt;();
  //set the array contents
  g.get(2).append("Something");
  </code></pre>
  
  <p>I know that doing something like </p>
  
  <pre><code>StringBuilder q=g.get(2);
  q.append("something else?");
  g.set(2,q);
  </code></pre>
  
  <p>works, and is probably the right way to do it, but it seems like such long way of doing it.</p>
  
  <p>Am I doing this right, if I'm not, then is the second way I've mentioned the only way?</p>