Array in Scala
In Scala arrays are immutable objects.
1
var myArray : Array[Int] = new Array[Int](10);
2
​
3
/*
4
To create an Array with String data type, replace
5
Int with String
6
*/
Copied!
First you declare variable var myArray to be of type Array[Int]. That is a Int array. If you had needed an array of e.g. String, replace String with String.
Array is 0 base indexing, meaning index starts from 0
Once created, length of an array can not be changed.
Last modified 1yr ago
Copy link