Is there any way in Java to create a method, which is expecting two different varargs? I know, with the same object kind it isn't possible because the compiler doesn't know where to start or to end. But why it also isn't possible with two different Object types?
For example:
public void doSomething(String... s, int... i){
//...
//...
}
Is there any way to create a method like this?
Thank you!
Stringwhile the other are of typeint; the compiler could infer where the first ends and the second begins, right?public void doSomething(A... as, B... bs)andBis a subtype ofA? On another note, Scala does support this by allowing multiple parameter lists on one method:def doSomething(as: A*)(bs: B*)