val 不可变,相当于Java中的final
Unit相当于Java中的void,以()表示
scala> val a = println("ddd")
ddd
a: Unit = ()
2,声明数组...输出结果
8
10
7
8,高阶函数
首先判断调用的layout方法是否满足apply的第一个函数参数,很明显,layout有一个Int的参数,返回的是字符串,完全符合f:Int => String,然后根据..., 60, 80)
ArrayBuffer(10, 30, 60, 80)
ArrayBuffer(10, 30, 60, 80)
ArrayBuffer(10, 30, 60, 80)
12,数组使用...tom,1), (hello,2))
list排序(降序)
scala> arr.flatMap(_.split(" ")).groupBy(x => x).mapValues(_.length).toList.sortBy...(x => - x._2)
res15: List[(String, Int)] = List((hello,2), (jenie,1), (tom,1))
13,集合使用
?