1import java.util.HashSet;
2public class HashSetContainsObjectMethodExample
3{
4 public static void main(String[] args)
5 {
6 HashSet<String> hs = new HashSet<String>();
7 hs.add("hello");
8 hs.add("world");
9 hs.add("java");
10 // check if element exists
11 boolean bool = hs.contains("world");
12 System.out.println("Is element 'world' exists: " + bool);
13 }
14}
1 HashSet<Integer> set = new HashSet<Integer>();
2set.contains(110)//public boolean contains(Object o)