Answers for "java list to iterator"

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
4

java iterate over list

for (int i = 0; i < crunchifyList.size(); i++) {
            System.out.println(crunchifyList.get(i));
        }
Posted by: Guest on February-28-2020
2

iterate a list using iterator

Iterator<String> crunchifyIterator = crunchifyList.iterator();
        while (crunchifyIterator.hasNext()) {
            System.out.println(crunchifyIterator.next());
        }
Posted by: Guest on May-20-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language