class ArrayUtils {

	@SuppressWarnings("unchecked")
	public static <T> T[] copyOfRange(T[] in, int start, int end) {
		int length = end - start;
		if (length < 0) {
			throw new IllegalArgumentException("end < start");
		}
		T[] out = (T[]) Array.newInstance(in.getClass().getComponentType(), length);
		if (length > 0) {
			System.arraycopy(in, start, out, 0, Math.min(length, in.length - start));
		}

		return out;
	}

}