scala 数组详解_scala 初始化数组-CSDN博客

网站介绍:文章浏览阅读3.3k次。1.初始化数组想要初始化数组,可以跟java里面一样,使用new关键字,指定数据类型与数组长度。 def test() = { val arr = new Array[Int](3) arr.foreach(x => print(x + ",")) }上面代码run起来以后:0,0,0,也可以不使用new关键字,直接提供初始值: def test(_scala 初始化数组