how to use contains in set code example

Example 1: 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);
   }    
}

Example 2: set.contains in javascript

const set = new Set();

set.add(1);
set.add(2);
set.add(3);

console.log(set.has(2));  //true
console.log(set.has(4)); //false