code: public static Object slice(List<Object> list, int from, int to, int step) {
          int length = list.size();
          if ( to > length ) to = length;
          if ( 0 > from ) from = 0;
          length = to - from;
          if ( 0 >= length )
              return list.subList(0, 0);
          if ( step == 0 || step == 1 )
              return list.subList(from, to);
          List<Integer> slices = new ArrayList<>();
          for ( int i = 0; i < length; i++ )
              if ( i % step == 0 )
                  slices.add(step < 0 ? length-1-i : i+from);
          return new SteppedSubList(list, slices);
      }
docs: Slice the supplied list for range and step.
  @param list to slice
  @param from start index inclusive
  @param to to index exclusive
  @param step size of step or 0 if no step
  @return a sliced view of the supplied list