A java list of strings can be returned from a Scala program by writing a user defined method of Java in Scala. Here, you don’t even need to import any Scala’s JavaConversions object in order to make this conversions work.
Now, lets see some examples.
Therefore, a list of strings is returned from a Java method. Here, you don’t need to import any object of Scala. In the above program a Java method is written in Scala program. Where, this method adds the string elements of the list to the stated list one after another and then prints the results.
[Nidhi, is an, author]
It is same as above example but here one more element is added in the stated list and here proper order of the elements is not required.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.