How I can iterate over Scala collections in Java?
Some example Scala
class AThing {
@scala.reflect.BeanProperty val aList = List(1,2,3,4,99)
}
A Java client
public class UseAThing {
public static void main(String a[]) {
AThing thing = new AThing();
scala.collection.Iterator iter = thing.getAList().iterator();
while (iter.hasNext()) {
System.out.println(iter.next());
}
}
}
Output
jem@Respect:~/c/user/jem$ java -cp /opt/scala/lib/scala-library.jar:. UseAThing
1
2
3
4
99
Does that help?