「Java8」forEach()でList、Map、配列の要素を取得する方法
方法1
public final static List<String> empLst = Arrays.asList(“Yamada", “Sugiyama", “Murasaki");
for(String emp : empLst) {
System.out.println(emp);
}
方法2
public final static List<String> empLst = Arrays.asList(“Yamada", “Sugiyama", “Murasaki");
empLst.forEach(emp -> System.out.println(emp));