Check out example codes for "how to iterate hashset in java 8". It will help you in understanding the concepts better.

Code Example 1

Set<String> set = new HashSet<String>();
for (String s : set) {
    System.out.println(s);
}

//Java 8:
set.forEach(System.out::println);

Learn ReactJs, React Native from akashmittal.com