Registrations Closing Soon for DevOps Certification Training by CloudxLab | Registrations Closing inEnroll Now
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".
No hints are availble for this assesment
Answer is not availble for this assesment
Note - Having trouble with the assessment engine? Follow the steps listed here