DEV Community

Harsha S
Harsha S

Posted on

Day 3 100 Days Of Code Challenge: - Revised functions of Set & HashMap

Today I revised the functions of a python set i.e.

Set is an unordered Collection of unique items.

a = set()
a = {1,2,3,4}
a.add(5)
a.remove(3)
a.discard(3)//does not give an error
a[1] # Not Allowed
a[3] = 10 # Not Allowed

HashMap is a dictionary.

Hashmap map = new Hashmap<>();
map.put("Harsha",10)
map.get("Harsha")
map.containsKey("Harsha")
map.containsValue(10)
map.remove(10)

Top comments (0)