28 Collections Summary - Accessing Elements
As a summary, all collections have a common syntax for accessing elements. Here is a recap
- You can access the elements of Arrays, Lists Maps and Sets using 
() - For Maps, accessing a key that doesn’t exist throws an exception: 
java.util.NoSuchElementException: key not foundto check if a key exists usemap.contains(key)or use a default value:map.getOrElse(key, defaultValue)