VOOZH about

URL: https://www.geeksforgeeks.org/scala/how-to-get-all-the-keys-from-a-scala-map/

⇱ How to get all the keys from a Scala map - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to get all the keys from a Scala map

Last Updated : 29 Jul, 2019
In order to get all the keys from a Scala map, we need to use either keySet method (to get all the keys as a set) or we can use keys method and if you want to get the keys as an iterator, you need to use keysIterator method. Now, lets check some examples. Example #1:
Output:
Set(3, 4, 2)
Here, keySet method is utilized. Example #2:
Output:
Set(3, 4, 2)
Here, keys method is utilized. Example #3:
Output:
non-empty iterator
Here, keysIterator method is utilized.
Comment
Article Tags:
Article Tags:

Explore