How to split a string into a list of strings in Scala

1 Answer

0 votes
object SplitStringIntoList {
  def main(args: Array[String]): Unit = {
    val str = "scala java c# c c++ python"

    val list = str.split(" ").toList

    println(s"List of strings: $list")
  }
}

  
     
/*
run:
  
List of strings: List(scala, java, c#, c, c++, python)

*/

 



answered Apr 3, 2025 by avibootz
...