Proper terminology for Object… args

谁说胖子不能爱 提交于 2019-12-03 10:44:23

This way to express arguments is called varargs, and was introduced in Java 5.
You can read more about them here.

The Parameter method(Object... args) is called varargs. Try this link.

As a Keppil and Steve Benett pointed out that this java feature is called varargs.

If I'm not mistaken, Joshua Bloch mentioned that there is a performance hit for using varargs and recommends telescoping and using the varargs method as a catch all sink.

public static void someMethod(Object arg) {
    // Do something
}

public static void someMethod(Object arg1, Object arg2) {
    // Do something
}

public static void someMethod(Object arg1, Object arg2, Object arg3) {
    // Do something
}

public static void someMethod(Object ... args) {
    // Do something
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!