how to use contains in set code example
Example 1: set contains in java
public class HashSetDemo {
public static void main(String args[]) {
HashSet <String> newset = new HashSet <String>();
newset.add("Learning");
newset.add("Easy");
newset.add("Simply");
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));
console.log(set.has(4));