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:
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 = (.....)
But, the above problem 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...