val buf = new ListBuffer[Int] val l1 = List(1,2,3,4,5) for (x<-l1) buf += x+1; println(buf) val l2 = buf.toList println(l2)
时间: 2024-11-02 22:28:51
val buf = new ListBuffer[Int] val l1 = List(1,2,3,4,5) for (x<-l1) buf += x+1; println(buf) val l2 = buf.toList println(l2)