Sorting out the basic knowledge points of Scala array
This article mainly explains the "Scala array of basic knowledge points collation", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "Scala array basic knowledge points collation" bar!
# # fixed length Array
Arrays generally include fixed-length arrays and variable-length arrays, which are declared using Array in Scala
Note: the index of scalad is marked with parentheses () rather than square brackets [] commonly used in other languages, and the index subscript starts at 0.
/ / declare an array of string type, with a length of 3, set a value for each element, and access the second element by index. Val a = new Array [String] (3) a (0) = "abc" a (1) = "edf" a (2) = "qaz" println (a (1))
The abbreviation of the array
Val a = Array ("1", "2", "3") println (a (1))
Traversal of array
Val list = Array ("5", "2", "3", "4") for (x