Check out example codes for "declare generic set java". It will help you in understanding the concepts better.

Code Example 1

Set<String> set = new HashSet<String>;

for(String aString : set) {
    System.out.println(aString);
}

Code Example 2

Set<String> set = new HashSet<String>;
    
Iterator<String> iterator = set.iterator();

while(iterator.hasNext()){
  String aString = iterator.next();
}

Learn ReactJs, React Native from akashmittal.com