Array list demo (#677)

* Create ArrayList demo

* Update code samples according to the article
This commit is contained in:
zinch84 2016-09-08 11:04:55 +03:00 committed by Grzegorz Piwowarek
parent 15d45cffd6
commit 7ba9a1288b

View File

@ -57,8 +57,8 @@ public class ArrayListTest {
@Test @Test
public void givenCollection_whenAddToArrayList_thenIsAdded() { public void givenCollection_whenAddToArrayList_thenIsAdded() {
List<Long> xs = new ArrayList<>(Arrays.asList(1L, 2L, 3L)); List<Long> xs = new ArrayList<>(Arrays.asList(1L, 2L, 3L));
Collection<Long> ys = LongStream.range(4, 10).boxed().collect(toList()); LongStream.range(4, 10).boxed()
xs.addAll(0, ys); .collect(collectingAndThen(toList(), ys -> xs.addAll(0, ys)));
assertThat(Arrays.asList(4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L), equalTo(xs)); assertThat(Arrays.asList(4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L), equalTo(xs));
} }