Answers for "set contains in java"

0

set contains in java

public class HashSetDemo {
   public static void main(String args[]) {
      
      // create hash set
      HashSet <String> newset = new HashSet <String>();

      // populate hash set
      newset.add("Learning"); 
      newset.add("Easy");
      newset.add("Simply");  

      // check the existence of element
      boolean exist = newset.contains("Simply");

      System.out.println("Is the element 'Simply' exists: "+ exist);
   }    
}
Posted by: Guest on October-22-2020

Python Answers by Framework

Browse Popular Code Answers by Language