Scala中的定长数组与可变数组

Scala中的定长数组与可变数组

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

package com.anthony

/**
* @ Description:
* @ Date: Created in 12:32 10/07/2018
* @ Author: Anthony_Duan
*/
object Array_test extends App {


val a = Array("hadoop","flink","spark")
println(a)
val b = Array(1,2,3,4,5,6)
println(b)
println(b.length)
println(b.toString)
println(b.mkString)
println(b.mkString("<",",",">"))

val c = scala.collection.mutable.ArrayBuffer[Int]()
c += 1
c += (2,3,4)
c ++= Array(5,6,7)
c.insert(2,100)
println(c)
println(c.remove(2,3))
println(c.max+" "+ c.min)

println(c.reverse)
for (ele <- c.reverse) {
println(ele)
}
for (i <- 0 until c.length){
println(c(i))
}
println(c)


c -= 1
c -= (2,3,4)
c --= Array(5,6)
println(c)
}
-------------End Of This ArticleThank You For Reading-------------