Login using Social Account
     Continue with GoogleLogin using your credentials
An 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".
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Loading comments...