title: append values dynamically into an long[] array
body: <p>i need some help regarding adding values into an array</p>
  
  <p>for example</p>
  
  <pre><code>long[] s = new long[] {0, 1, 2};
  </code></pre>
  
  <p>when i do this i instantiate an array with the values</p>
  
  <p>but how do i append to this to the above array if i have another value of</p>
  
  <pre><code>3, 4, 5
  </code></pre>
  
  <p>to make it like this</p>
  
  <pre><code>s = new long[] {1, 2, 3, 4, 5, 6};
  </code></pre>
  
  <p>i tried the System.arraycopy function but i am only able to overide the array and when i try to append to it, i get a null pointer exception</p>
  
  <p>Thanks</p>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>i used this with a for loop to put in the values once by one</p>
  
  <pre><code>        long[] tmp = new long[a.length + x.length];
      System.arraycopy(a, 0, tmp, 0, a.length);
      System.arraycopy(x, 0, tmp, a.length, x.length);
      a=tmp;
  </code></pre>