Assuming you have the following list: List<String> list = Arrays.asList("a", "b", "c", "d", "e", "f"); if you want to do something by using each element in a collection, there are two ways: 1) list.forEach(s -> System.out.println(s)); 2) for(String s: list){ System.out.println(s); } Both of the above two ways print the elements in sequential: a b […]
↧