Answers for "java iterables to list"

2

java Iterable to list

@Test
public void whenConvertIterableToListUsingJava8_thenSuccess() {
    List<String> result = new ArrayList<String>();
    iterable.forEach(result::add);

    assertThat(result, contains("john", "tom", "jane"));
}
Posted by: Guest on January-13-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language