java slice an array code example Example: array slice java int[] newArray = Arrays.copyOfRange(oldArray, startIndex, endIndex);