i need some help regarding adding values into an array
for example
long[] s = new long[] {0, 1, 2};
when i do this i instantiate an array with the values
but how do i append to this to the above array if i have another value of
3, 4, 5
to make it like this
s = new long[] {1, 2, 3, 4, 5, 6};
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
Thanks
SOLUTION
i used this with a for loop to put in the values once by one
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;
See Question&Answers more detail:os