@SuppressWarnings("unchecked") public static <T>T[] appendElement(Class<T> kind,T[] array,T element){
  final T[] result;
  final int end;
  if (array != null) {
    end=array.length;
    result=(T[])Array.newInstance(kind,end + 1);
    System.arraycopy(array,0,result,0,end);
  }
 else {
    end=0;
    result=(T[])Array.newInstance(kind,1);
  }
  result[end]=element;
  return result;
}

@ SuppressWarnings ( "unchecked" ) public static < T > T [ ] appendElement ( Class < T > kind , T [ ] array , T element ) { final T [ ] result ; final int end ; if ( array != null ) { end = array . length ; result = ( T [ ] ) Array . newInstance ( kind , end + 1 ) ; System . arraycopy ( array , 0 , result , 0 , end ) ; } else { end = 0 ; result = ( T [ ] ) Array . newInstance ( kind , 1 ) ; } result [ end ] = element ; return result ; }
appends an element to a copy of the array and returns the copy .
