Using Scala from Java: passing functions as parameters
In the scala.runtime package, there are abstract classes named AbstractFunction1 and so on for other arities. To use them from Java you only need to override apply, like this: Function1<Integer, String> f = new AbstractFunction1<Integer, String>() { public String apply(Integer someInt) { return myFunc(someInt); } }; If you’re on Java 8 and want to use … Read more