package com.github.droidfu.support;


public class ArraySupport {

    @SuppressWarnings("unchecked")
    public static <T> T[] join(T[] one, T[] two) {
        if (one == null) {
            return two;
        }
        if (two == null) {
            return one;
        }
        Object[] array = new Object[one.length + two.length];

        System.arraycopy(one, 0, array, 0, one.length);
        System.arraycopy(two, 0, array, one.length, two.length);

        return (T[]) array;
    }

}

@@ -30,16 +30,49 @@
 pport;%0A%0A
+import java.lang.reflect.Array;%0A%0A
 %0Apublic 
@@ -167,20 +167,22 @@
 T%5B%5D 
-one
+head
 , T%5B%5D t
-wo
+ail
 ) %7B%0A
@@ -193,19 +193,20 @@
     if (
-one
+head
  == null
@@ -229,18 +229,19 @@
 return t
-wo
+ail
 ;%0A      
@@ -257,18 +257,19 @@
    if (t
-wo
+ail
  == null
@@ -291,19 +291,20 @@
  return 
-one
+head
 ;%0A      
@@ -319,39 +319,111 @@
     
-Object%5B%5D array = new Object%5Bone
+Class type = head.getClass().getComponentType();%0A        T%5B%5D array = (T%5B%5D) Array.newInstance(type, head
 .len
@@ -433,18 +433,19 @@
  + t
-wo
+ail
 .length
-%5D
+)
 ;%0A%0A 
@@ -468,19 +468,20 @@
 raycopy(
-one
+head
 , 0, arr
@@ -487,19 +487,20 @@
 ray, 0, 
-one
+head
 .length)
@@ -527,18 +527,19 @@
 aycopy(t
-wo
+ail
 , 0, arr
@@ -542,19 +542,20 @@
  array, 
-one
+head
 .length,
@@ -560,10 +560,11 @@
 h, t
-wo
+ail
 .len

use reflection to instantiate array, is a wee bit slower but allows using generics