hashset contains 28object o 29 method in java

Solutions on MaxInterview for hashset contains 28object o 29 method in java by the best coders in the world

showing results for - "hashset contains 28object o 29 method in java"
Emeline
16 Mar 2020
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}