Search code examples
javaparametersvariadic-functionsmethod-signature

Why is varargs always the last parameter in a method signature?


Why does varargs have to be the last parameter in method signature?

I want to know the reason.


Solution

  • Because it makes the compiler's life simpler. There's no real reason why it couldn't have more arguments after, but it would require a much more complex compiler and so the spec was written that way.