I have a Set in Scala (I can choose any implementation as I am creating the Set. The Java library I am using is expecting a java.util.Set[String].
Is the following the correct way to do this in Scala (using scala.collection.jcl.HashSet#underlying):
var classes = new scala.collection.jcl.HashSet[String]
classes += "Amphibian"
classes += "Reptile"
error: type mismatch;
found : scala.collection.jcl.HashSet[String]
If you were asking about Scala 2.8, Java collections interoperability is supplied by
scala.collection.JavaConversions. In this case, you want JavaConversions.asSet(...) (there's one for each direction, Java -> Scala and Scala -> Java).
For Scala 2.7, each scala.collection.jcl class that wraps a Java collection has an
underlying property which provides the wrapped Java collection instance.