开发者

What was the alternative syntax to passing an array as a parameter in a method signature?

开发者 https://www.devze.com 2023-02-13 01:22 出处:网络
I\'ve seen the syntax before and it\'s close to the form of public void foo( Obj开发者_JAVA技巧ect object1, Object ... ){}

I've seen the syntax before and it's close to the form of

public void foo( Obj开发者_JAVA技巧ect object1, Object ... ){}

Does anyone know the exact syntax or have a link to further information?


In Java it is called varargs.

public void foo(Object object, Object... objects) {
    // the 'objects' argument is an array here.
}


You almost had it,

public void foo( Object object1, Object... objects ){}


Maybe you are looking for this?


Java "params" in method signature?

may be what you are looking for.

0

精彩评论

暂无评论...
验证码 换一张
取 消