Hi,
Yes, "foreach" function you use because it will print each and every element of the string using "println" function.
scala> str.fe=foreach(println)
You can see that each of Test string has displayed accordingly.
Hope this helps!
If you want to know more about Apache Spark Scala, It's highly recommended to go for Spark certification course today.
Thanks!!