object ArrayLearn {
def main(args: Array[String]): Unit = {
//定长数组的定义
val arr1 = Array(1, 2, 3)
println(arr1)
val arr2 = Array[Int](4, 2, 3)
println(arr2.length)
println(arr2(0))
arr2(0) = 90
println(arr2(0))
val arr3 = new Array[Int](10)
println(arr3)
val arr4 = new Array(10)
println(arr4)
//定长数组的求和
//方法1:直接调用sum方法求和
println(arr2.sum)
//遍历求和
var sum = 0
for (e <- arr2) sum += e
println(sum)
println(arr2.max)
println(arr2.min)
val arr5 = arr2.sorted
println(arr5(0))
val arr6 = arr2.sorted.reverse
println(arr6(0))
}
}