Working with Lists
Lists are probably the most common data structure used in Scala. In the following lesson, you will learn how to create a List.
Introduction
A List in Scala is a collection which comes under the Seq
class. It is an immutable collection and hence when modified the original List does not get updated, rather, a new List is created.
Like Arrays and ArrayBuffers, Lists store elements of the same type.
Creating a List
Lists can be created and populated in multiple different ways, most of which are identical to the approaches we went over when discussing Arrays. Let’s quickly go over them.
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy