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)
![](https://www.edureka.co/community/?qa=blob&qa_blobid=9945476341641939017)
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!!