code: @SuppressWarnings("unchecked")
    public static <T> T[] subArray(T[] array, int... indices) {
  
      List<T> subArrayList = new ArrayList<>(indices.length);
  
      for (int index : indices) {
        subArrayList.add(array[index]);
      }
  
      return subArrayList.toArray((T[]) Array.newInstance(array.getClass().getComponentType(), subArrayList.size()));
    }
docs: Creates a sub-array from the given array with elements at the specified indices in the given array.
  
  @param <T> the Class type of the elements in the array.
  @param array the source array.
  @param indices an array of indexes to elements in the given array to include in the sub-array.
  @return a sub-array from the given array with elements at the specified indices in the given array.
  @throws ArrayIndexOutOfBoundsException if the indices are not valid indexes in the array.
  @throws NullPointerException if either the array or indices are null.