java set for each code example
Example 1: how to iterate hashset in java 8
Set<String> set = new HashSet<String>();
for (String s : set) {
System.out.println(s);
}
//Java 8:
set.forEach(System.out::println);
Example 2: java set foreach
Set<String> set = new HashSet<String>();
//populate set
for (String s : set) {
System.out.println(s);
}