title: How can I dynamically add items to a Java array?
body: <p>In PHP, you can dynamically add elements to arrays by the following:</p>
  
  <pre><code>$x = new Array();
  $x[] = 1;
  $x[] = 2;
  </code></pre>
  
  <p>After this, <code>$x</code> would be an array like this: <code>{1,2}</code>.</p>
  
  <p>Is there a way to do something similar in Java?</p>