code: public static Object[] subarray(Object[] array, int startIndexInclusive, int endIndexExclusive) {
          int newSize = endIndexExclusive - startIndexInclusive;
          Class<?> type = array.getClass().getComponentType();
          if (newSize <= 0) {
              return (Object[]) Array.newInstance(type, 0);
          }
          Object[] subarray = (Object[]) Array.newInstance(type, newSize);
          System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
          return subarray;
      }
docs: originally licensed under ASL 2.0