public static <T> T[] copyOfRange(T[] original, int start, int end) {int originalLength = original.length; if (start > end) {throw new IllegalArgumentException();}if (start < 0 || start > originalLength) {throw new ArrayIndexOutOfBoundsException();}int resultLength = end - start;int copyLength = Math.min(resultLength, originalLength - start);T[] result = (T[]) Array.newInstance(original.getClass().getComponentType(), resultLength);System.arraycopy(original, start, result, 0, copyLength);return result;}

public static < T > T [ ] copyOfRange ( T [ ] original , int start , int end ) { int originalLength = original . length ; if ( start > end ) { throw new IllegalArgumentException ( ) ; } if ( start < 0 || start > originalLength ) { throw new ArrayIndexOutOfBoundsException ( ) ; } int resultLength = end - start ; int copyLength = Math . min ( resultLength , originalLength - start ) ; T [ ] result = ( T [ ] ) Array . newInstance ( original . getClass ( ) . getComponentType ( ) , resultLength ) ; System . arraycopy ( original , start , result , 0 , copyLength ) ; return result ; }
public static int[] copyOfRange(int[] original, int start, int end){if (start > end){throw new System.ArgumentException();}int originalLength = original.Length;if (start < 0 || start > originalLength){throw new System.IndexOutOfRangeException();}int resultLength = end - start;int copyLength = System.Math.Min(resultLength, originalLength - start);int[] result = new int[resultLength];System.Array.Copy(original, start, result, 0, copyLength);return result;}
