public static Object[] add(Object[] array, Object element) {
        Class type;
        if (array != null){
            type = array.getClass();
        } else if (element != null) {
            type = element.getClass();
        } else {
            type = Object.class;
        }
        Object[] newArray = (Object[]) copyArrayGrow1(array, type);
        newArray[newArray.length - 1] = element;
        return newArray;
    }
public static Object [ ] add ( Object [ ] array , Object element ) { Class type ; if ( array != null ) { type = array . getClass ( ) ; } else if ( element != null ) { type = element . getClass ( ) ; } else { type = Object . class ; } Object [ ] newArray = ( Object [ ] ) copyArrayGrow1 ( array , type ) ; newArray [ newArray . length - 1 ] = element ; return newArray ; }
<p>Copies the given array and adds the given element at the end of the new array.</p>

<p>The new array contains the same elements of the input
array plus the given element in the last position. The component type of
the new array is the same as that of the input array.</p>

<p>If the input array is <code>null</code>, a new one element array is returned
whose component type is the same as the element, unless the element itself is null,
in which case the return type is Object[]</p>

<pre>
ArrayUtils.add(null, null)      = [null]
ArrayUtils.add(null, "a")       = ["a"]
ArrayUtils.add(["a"], null)     = ["a", null]
ArrayUtils.add(["a"], "b")      = ["a", "b"]
ArrayUtils.add(["a", "b"], "c") = ["a", "b", "c"]
</pre>

@param array  the array to "add" the element to, may be <code>null</code>
@param element  the object to add, may be <code>null</code>
@return A new array containing the existing elements plus the new element
The returned array type will be that of the input array (unless null),
in which case it will have the same type as the element.
@since 2.1