I'm trying to merge 2 int arrays using this custom function I found on Google:
public static <T> T[] arrayMerge(T[]... arrays)
{
int count = 0;
for (T[] array : arrays) count += array.length;
T[] mergedArray = (T[]) Array.newInstance(arrays[0][0].getClass(),count);
int start = 0;
for (T[] array : arrays) {
System.arraycopy(array, 0, mergedArray, start, array.length);
start += array.length;
}
return (T[]) mergedArray;
}
but I'm fail to understand what parameters this function takes. I was hoping it would work like arrayMerge(int[], int[]), but Eclipse tells me it doesn't take these arguments. I can't Google a capital T to find an answer.
You can answer in a form or reading material, but an example of using this function to merge 2 int arrays would be nice (does it eliminate duplicates, if not, how can I also achieve that?).