Java multiple arguments dot notation - Varargs

前端 未结 2 1576
北恋
北恋 2020-12-13 01:44

I\'ve just acknowledged dot notation for method declaration with multiple arguments
like this:

public function getURLs(URL... urls){
    for(int i = 0; i         


        
2条回答
  •  星月不相逢
    2020-12-13 02:25

    Yes, that is how it works. The arguments are automatically put into an array. The argument "urls" behaves like a URL[]. Varargs are documented here. They were introduced in Java 1.5, so, are available in J2SE 1.5+, and all of Android since it supports Java 1.5+ language features. No version of JavaME/J2ME supports it.

提交回复
热议问题