BAEL-3938: Add new section on Java 10 Collectors.toUnmodifiableList() (#10488)

* Add java10 examples in the style of the existing examples

The existing examples in core-java-streams-2 module still had system out in them instead of assertions, so I kept that style to keep the article consistent.

* Remove code example that is not in the article
This commit is contained in:
mdhtr
2021-03-07 23:51:30 +01:00
committed by GitHub
parent ad80720713
commit 91fff1c069
2 changed files with 21 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
package com.baeldung.java10.streams;
import static java.util.stream.Collectors.toUnmodifiableList;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
public class StreamToImmutableJava10UnitTest {
@Test
public void whenUsingCollectorsToUnmodifiableList_thenSuccess() {
List<String> givenList = Arrays.asList("a", "b", "c");
List<String> result = givenList.stream()
.collect(toUnmodifiableList());
System.out.println(result.getClass());
}
}