Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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"));
}
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged: #java #Iterable #list
ADD COMMENT
Topic
Name
8+8 =