Collections are the container of things that contains a random number of elements.
Scala collections can be of two types basically:
Mutable Collection
- Collections are containers of things.
- These containers can be Sequenced, Linear set of items like List, Tuple, Map etc.
- Collections may have an arbitrary number of elements or be bounded to Zero or one element.
- The Scala collection classes are part of scala.collection package and its sub packages.
Scala collections can be of two types basically:
Mutable Collection
- These collections are part of scala.collection.mutable package.
- With these collections, we can add, remove or modify data.
- These collections are part of scala.collection.immutable package.
- This doesn’t allow to modify the data.
- Scala imports this package by default.
- To use mutable collection, we need to explicitly import the mutable package
in code. - Any change in an immutable collection, produces a new collection without
modifying the existing collection.
Most Common Collection types are –
- List
- Map
- Set
- Tuple
- Iterators
No comments:
Post a Comment