code: public static <T> T[] addToArray(T[] array, T item, Class<?> type) {
          if (array == null) {
              if (type == null && item != null) {
                  type = item.getClass();
              }
              @SuppressWarnings("unchecked")
              T[] na = (T[]) Array.newInstance(type, 1);
              na[0] = item;
              return na;
          } else {
              T[] na = Arrays.copyOf(array, array.length + 1);
              na[array.length] = item;
              return na;
          }
      }
docs: Add element to an array
  
  @param array The array to add to (or null)
  @param item  The item to add
  @param type  The type of the array (in case of null array)
  @param <T>   the array entry type
  @return new array with contents of array plus item