I have 2 simple methods in a scala library class:
class Foo {
def bar(args : String*) : Unit = println("Foo.bar with: " + args)
def bar(args : Array[String]) : Unit = bar(args.toSeq : _*)
}
This all compiles nicely. I then put this in a library foo.jar
and try and compile the following piece of Java:
import Foo
public class Test {
public static void main(String[] args) {
Foo foo = new Foo();
foo.bar("Hello", "World"); //DOES NOT COMPILE
}
}
I can replace the offending line with:
foo.bar(new String[] { "Hello", "World" }); //OK
But this seems to defeat the point. How can I call it from Java using Java varargs-like syntax?