Scala collection framework is a set of very rich and user friendly collection classes. And functional capabilities of Scala makes these collections safe, easy to use, concise, fast and universal. Here in this post we’ll take an overview of Scala collection classes.
By definition, collections are the dynamic growing group of objects of the same type, which enables certain operation on that group of data using some easy to use methods.
If you are not able to digest above definition let’s make it simple.
Collection classes are,
- Group of same type of objects, means this group can be list, set or map
- Dynamically growing, means size of this group can grow with writing any specific code
- Solve problems on group of data, means can solve problems like iteration, finding size of group, adding or removing elements in group, accessing elements in group (even on any position), transforming data (like mapping data to another value)
- Easy to use methods, means it provides intuitive set of methods to perform above operation which are user friendly
I hope you get this. Let’s move on…..
Now, In Scala there is a package
scala.collection which consist of all abstract classes and traits.
All of above classes/traits have respective mutable as well as immutable implementation in
When you talk about collections; List, Set and Map are the core collection types which are widely used. Below are my posts which will explain you all of these collection types with relevant code examples,