How to create a scala.collection.immutable.Seq from a Java List in Java?

前端 未结 4 1504
我寻月下人不归
我寻月下人不归 2020-12-15 03:45

I\'m trying to get Akka going in my Java project, and I\'m hung up on a small issue with the Seq type(s) from Scala. I\'m able to convert my Java List of ActorRef into a sc

相关标签:
4条回答
  • 2020-12-15 04:13

    You can try this:

    scala.collection.JavaConverters.asScalaIteratorConverter(list.iterator()).asScala().toSeq();
    
    0 讨论(0)
  • 2020-12-15 04:17

    You can use:

    scala.collection.JavaConverters.collectionAsScalaIterableConverter(workers).asScala().toSeq()

    0 讨论(0)
  • 2020-12-15 04:18

    You can use scala.collection.JavaConversions.asScalaBuffer to convert the Java List to a Scala Buffer, which has a toList method, and a Scala List is a collection.immutable.Seq.

    0 讨论(0)
  • 2020-12-15 04:36

    The akka Java documentation for routers as well as the ScalaDoc for CyclicIterator both suggest that the CyclicIterator constructor takes a List.

    0 讨论(0)
提交回复
热议问题