Buffer implements Iterable<T> { public Object[] toArray() { return toArray(Object[]::new); } private  Buffer(final int capacity); int capacity(); int size(); boolean isEmpty(); void add(final T value); @SafeVarargs final void addAll(final T... values); void addAll(final Iterable<? extends T> values); @Override Iterator<T> iterator(); Object[] toArray(); A[] toArray(final IntFunction<A[]> generator); ISeq<T> toSeq(); @Override String toString(); static Buffer<T> ofCapacity(final int capacity);  }
@Test public void toArray() { final Buffer<Integer> buffer = Buffer.ofCapacity(5); final Object[] array = buffer.toArray(Integer[]::new); Assert.assertEquals(array.length, 0); }