Learn a little Array of Scala every day
How to learn arrays? It can be considered from the following scheduling
1. You can create an array in the following ways:
Method 1: use new to create and scala to infer types automatically
Method 2: use new to create and add type declaration
Val b = new Array [Int] (10)
Method 3: do not use new, initialize the array when creating the array
Val placeName = Array ("beijing", "shanghai", "guangzhou")
Method 4: use range
2. Initialize the array
3. How do I access the elements in the array?
Access the elements of an array through an index
Println ("- >:\ t" + b (2)) / / unlike java, it is through parentheses.