Enrollments closing soon for Post Graduate Certificate Program in Applied Data Science & AI By IIT Roorkee | 3 Seats Left
Apply NowLogin using Social Account
     Continue with GoogleLogin using your credentials
A list is another collection available in Scala.
A list is similar to an array but lists are immutable which means that the elements of a list cannot be changed by assignment and the lists represent a linked list whereas the arrays are flat.
for example, the list of days in week:
// Make a list via the companion object factory
val days = List("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
Here is an example of a list of numbers:
val mainList = List(3, 2, 1)
Declare the list in Jupyter named strList
, having these elements in the same order:
Here, we must define the variable as a list of Strings as is the requirement above.
Note that the list is displayed with its contents. Once you have run the scala code using SHIFT+ENTER, please click on "Submit Answer".
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...