Why won't Java pass int[] to vararg? [duplicate]

一个人想着一个人 提交于 2019-11-30 15:45:43

Fix this in your code and it'll work:

static void prints(int... ints) // notice the static keyword at the beginning!

The problem is not with the varargs, it's with the way you're calling an instance method from a static context. Also, make extra-sure that there are no other methods with conflicting signatures, for example these two methods will look the same to the compiler:

void prints(int... ints)
void prints(int[]  ints)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!