Oct
01
|
Create a new array big enough to hold both, then use System.arraycopy() to copy two arrays into new concatentated array.
// two arrays to be concatenated Object[] a = getArrayA(); Object[] b = getArrayB(); // create new array Object[] concatenated = new Object[a.length + b.length]; // Copy contents of a System.arraycopy(a, 0, concatenated, 0, a.length); // Copy contents of b (after a) System.arraycopy(b, 0, concatenated, a.length, b.length);
Leave a Reply
You must be logged in to post a comment.