Skip to content
Advertisement

Java two varargs in one method

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:

JavaScript

Is there any way to create a method like this?

Thank you!

Advertisement

Answer

Only one vararg, sorry. But using asList() makes it almost as convenient:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement