@SuppressWarnings("unchecked")
	public static <T> T[] addElemToArray(T[] array, T element, int index) {
		if (array == null) {
			array = (T[]) Array.newInstance(element.getClass(), (index + 1));
			array[index] = element;
			return array;
		}
		if (index < array.length) {
			array[index] = element;
			return array;
		} else {
			T[] newArray = (T[]) Array.newInstance(element.getClass(), (index + 1));
			System.arraycopy(array, 0, newArray, 0, array.length);
			newArray[index] = element;
			return newArray;
		}
	
	}