27 Collections - Accessing Elements

  • 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 found to check if a key exists use map.contains(key) or use a default value: map.getOrElse(key, defaultValue)

Code editor is using Scalakata.com written by Guillaume Massé