Skip to content
Advertisement

Tag: variadic-functions

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: Is there any way to create a method like this?

Varargs in method overloading in Java

The following code doesn’t compile. A compile-time error is issued. reference to test is ambiguous, both method test(int…) in varargspkg.Main and method test(float…) in varargspkg.Main match It seems to be obvious because the parameter values in the method call test(1, 2); can be promoted to int as well as float If anyone or both of the parameters are suffixed by

Advertisement