二维数组下面多种方法:
可以循环
[mw_shl_code=scala,true]def dim2B(rows : Int):Array[ArrayBuffer[Int]]={
val d2 :Array[ArrayBuffer[Int]] = new Array(rows)
for (k <-0 until rows ) {
d2(k) = new ArrayBuffer[Int]()
}
d2
}
val index = dim2B(10)[/mw_shl_code]
或则for循环
[mw_shl_code=scala,true]var index = new Array[ArrayBuffer[Int]](10)
for(i <- 0 until index.length){
index(i) = new ArrayBuffer[Int]()
}[/mw_shl_code]