Which of the following compile? (Choose all that apply)
A. public void methodA(int... nums) {} B. public void methodB(String values, int... nums) {} C. public void methodC(int... nums, String values) {} D. public void methodD(String... values, int... nums) {} E. public void methodE(String[] values, ...int nums) {} F. public void methodF(String... values, int[] nums) {} G. public void methodG(String[] values, int[] nums) {}
A, B, G.
Options A and B are correct because the single vararg parameter is the last parameter declared.
Option G is correct because it doesn't use any vararg parameters at all.
Options C and F are incorrect because the vararg parameter is not last.
Option D is incorrect because two vararg parameters are not allowed in the same method.
Option E is incorrect because the ... for a vararg must be after the type, not before it.