I need to implement a method that returns a Scala Seq
, in Java.
But I encounter this error:
java.util.ArrayList cannot be cast to scala.
@Fundhor, the method asScalaIterableConverter
was not showing up in the IDE. It may be due to a difference in the versions of Scala. I am using Scala 2.11. Instead, it showed up asScalaIteratorConverter
. I made a slight change to your final snippet and it worked fine for me.
scala.collection.JavaConverters.asScalaIteratorConverter(columnNames.iterator()).asScala().toSeq()
where columnNames
is a java.util.List
.
thanks !