import java.util.HashSet;
import java.util.Iterator;
public class SetDemo {
public static void main(String[] args) {
HashSet<String> hSet = new HashSet<>();
hSet.add("one");
hSet.add("two");
hSet.add("three");
hSet.add("zero");
System.out.println(hSet.contains("three"));
Iterator<String> iterator = hSet.iterator();
while (iterator.hasNext()) {
String string = (String) iterator.next();
System.out.println(string);
}
}
}
import java.util.Iterator;
public class SetDemo {
public static void main(String[] args) {
HashSet<String> hSet = new HashSet<>();
hSet.add("one");
hSet.add("two");
hSet.add("three");
hSet.add("zero");
System.out.println(hSet.contains("three"));
Iterator<String> iterator = hSet.iterator();
while (iterator.hasNext()) {
String string = (String) iterator.next();
System.out.println(string);
}
}
}