Javatpoint Logo
Javatpoint Logo

Scala Vector

Vector is a general-purpose, immutable data structure. It provides random access of elements. It is good for large collection of elements.

It extends an abstract class AbstractSeq and IndexedSeq trait.

Scala Vector Example


Vector(5, 8, 3, 6, 9, 4)
Vector(5, 2, 6, 3)

Scala Vector Example

In the following example, we have created a vector. You can also add new element and merge two vectors.


Vector Elements: Hocky Cricket Golf 
Vector Elements after adding: Hocky Cricket Golf Racing 
Vector Elements after merging: Hocky Cricket Golf Racing Swimming 
Vector Elements after reversing: Swimming Racing Golf Cricket Hocky 
Vector Elements after sorting: Cricket Golf Hocky Racing Swimming
Next TopicScala List

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA