Get the App
SLTechnology News&Howtos  ›  Servers  › 

Learn a little Array of Scala every day

Shulou Source: shulou.com Published: 2022-06-02 16:18:09 09月11日 Update

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.

Tags: Arrays modes elements types differences parentheses learning inference scheduling Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MySQL Shulou Information macOS vpn