code: public static <T> Collector<T, ?, List<T>> last(final int n) {
          N.checkArgNotNegative(n, "n");
  
          final Supplier<Deque<T>> supplier = new Supplier<Deque<T>>() {
              @Override
              public Deque<T> get() {
                  return n <= 1024 ? new ArrayDeque<T>(n) : new LinkedList<T>();
              }
          };
  
          final BiConsumer<Deque<T>, T> accumulator = new BiConsumer<Deque<T>, T>() {
              @Override
              public void accept(Deque<T> dqueue, T t) {
                  if (n > 0) {
                      if (dqueue.size() >= n) {
                          dqueue.pollFirst();
                      }
  
                      dqueue.offerLast(t);
                  }
              }
          };
  
          final BinaryOperator<Deque<T>> combiner = new BinaryOperator<Deque<T>>() {
              @Override
              public Deque<T> apply(Deque<T> a, Deque<T> b) {
                  if (N.notNullOrEmpty(a) && N.notNullOrEmpty(b)) {
                      throw new UnsupportedOperationException("The 'first' and 'last' Collector only can be used in sequential stream");
                  }
  
                  while (b.size() < n && !a.isEmpty()) {
                      b.addFirst(a.pollLast());
                  }
  
                  return b;
              }
          };
  
          final Function<Deque<T>, List<T>> finisher = new Function<Deque<T>, List<T>>() {
              @Override
              public List<T> apply(Deque<T> dqueue) {
                  return new ArrayList<>(dqueue);
              }
          };
  
          return new CollectorImpl<>(supplier, accumulator, combiner, finisher, CH_NOID);
      }
docs: Only works for sequential Stream.
  
  @param n
  @return
  @throws UnsupportedOperationException operated by multiple threads