Scala循环操作

val buf = new scala.collection.mutable.ArrayBuffer[Int]

for (i <- 0 to 10) {
buf += i
}
buf += 11

buf.foreach(u =>println(u + "\t"))


val bufPerson = new scala.collection.mutable.ArrayBuffer[Person]

for (i <- 0 to 10) {
bufPerson += new Person("Alice"+i, 25);
}
bufPerson.foreach(u =>println(u + "\t"))
// 数组

posted @ 2016-04-28 16:07  小毛驴  阅读(254)  评论(0编辑  收藏  举报