As DwB suggests in the comments
Try this:
int[] blam = {1}; method(blam); method(1, blam);
In other words, you can still call the method you want by using values of type int[]
where a vararg is declared.
Question
The following 2 lines of code compile OK. However, I think it's unuseable, because I can't think of any method invocations that will work with it.
// If I can't use this code, why not warn me about it?
void method(int... x) { }
void method(int x, int... y) { }
For instance, the following 2 lines of code both cause the javac compiler to issue an error message about varargs ambiguity.
// Both invocations fail to compile.
method(1);
method(1,1);
I wondered if the javac compiler had its warnings messages disabled by default, and so I tried compiling my code with the javac -Xlint option, but that didn't change things. Any comments gratefully received. Thank you.
Solution
As DwB suggests in the comments
Try this:
int[] blam = {1}; method(blam); method(1, blam);
In other words, you can still call the method you want by using values of type int[]
where a vararg is declared.