Skip to content

Commit 7ba9a12

Browse files
zinch84pivovarit
authored andcommitted
Array list demo (eugenp#677)
* Create ArrayList demo * Update code samples according to the article
1 parent 15d45cf commit 7ba9a12

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎core-java/src/test/java/org/baeldung/java/collections/ArrayListTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public void givenElement_whenAddToArrayList_thenIsAdded() {
5757
@Test
5858
public void givenCollection_whenAddToArrayList_thenIsAdded() {
5959
List<Long> xs = new ArrayList<>(Arrays.asList(1L, 2L, 3L));
60-
Collection<Long> ys = LongStream.range(4, 10).boxed().collect(toList());
61-
xs.addAll(0, ys);
60+
LongStream.range(4, 10).boxed()
61+
.collect(collectingAndThen(toList(), ys -> xs.addAll(0, ys)));
6262

6363
assertThat(Arrays.asList(4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L), equalTo(xs));
6464
}

0 commit comments

Comments
 (0)