Program to convert Java list of Strings to Traversable in Scala
A java list of Strings can be converted to a Traversable collection in Scala by utilizing toTraversable method of Java in Scala. Here, you need to import Scala’s JavaConversions object in order to make this conversions work.
Now, lets see some examples and then discuss how it works in details.
Buffer(i, am, good)
Here, the stated output is in same order as stated in the given list.
Buffer(i, am a, girl)
Here, the strings with lesser number of words are displayed first and strings of greater length are displayed at last.
My Personal Notes arrow_drop_up
Please Login to comment...