package test_33 import scala.io.Source object test { def main(args: Array[String]): Unit = { val content = Source.fromFile("1.txt").mkString val arr = content.split("\\W+") arr.foreach(println) val arr1 = Array("thank", "you", "very", "much", "thank", "very") val m1 = scala.collection.mutable.Map[String, Int]() arr1.foreach(word => { if (m1.contains(word)) { m1(word) += 1 } else { m1(word) = 1 } }) m1.foreach{ case (word,cishu) => println(s"${word}: ${cishu}")} } }