Enrollments Open for Advanced Certification Courses on Data Science, ML & AI by E&ICT Academy IIT Roorkee
Apply NowAn array is one of the collections in Scala, which stores a fixed-size sequential collection of elements of the same type.
We will declare an array of strings, named strArray
, having below elements in the same order.
Elements of the array:
John
Doe
Jane
Sach
In general, providing the datatype of the variable is optional. So, an array can be defined in either of the below ways:
var ar:Array[String] = Array(.....)
var ar = Array(.....)
But, the first statement specifies that the array will consist of strings only, so :Array[String]
is required here.
Switch to the Jupyter tab.
Declare the array of the required name and having required items in the Jupyter.
Press Shift+Enter. You should see the output showing the array name and its content.
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
Loading comments...