Scala and Java collaboration
Going back to the REPL, we are going to experiment further with mixing Scala and Java to explore some common integration needs, and in particular, testing and manipulating the Java REST API that we have built at the beginning of the chapter.
As a reminder on how to restart the REPL from the hello-scala project introduced in Chapter 1, Programming Interactively within Your Project, if you closed it in the meantime, just start a new terminal window, navigate to the root of the hello-scala project, and enter the following command in the command prompt:
> ./activator console
Converting between collection types
Let's start by comparing Java and Scala collection classes and see how we can go from one to the other. For instance, a Scala List
(from the scala.collection.immutable
package) is different from java.util.List
, and sometimes, it can be useful to convert from one to the other. A convenient way in Java to create java.util.List
is to use the java.util.Arrays
...