How to count the number of words in a string with Scala

1 Answer

0 votes
object Main extends App {
  val str = "scala javascript php c c++"
  
  val len = str.split(" ").length
  
  println(len)
}




/*
run:

5

*/

 



answered Sep 20, 2024 by avibootz
...