The best place to ask programming/development questions, imo. UPDATE: stackoverflow is the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but a great reference for finding answers.

My Music (Nickleus)


three dots (ellipsis)/periods/full stops in java method parameter: "WebServiceFeature... features"

in my last post:
java webservices wsimport - parsing WSDL [ERROR] Server returned HTTP response code: 401 for URL: http://?wsdl needs authorization

i created a webservice client by using the commandline tool wsimport. in the generated code i noticed that one of the methods looked like this:

@WebEndpoint(name = "AdminWebService")
public AdminWebService getAdminWebService(WebServiceFeature... features) {
    return super.getPort(new QName("http://server3.wservice3", "AdminWebService"), AdminWebService.class, features);

notice the three dots (ellipsis) in the method parameters:
getAdminWebService(WebServiceFeature... features)

i wondered if this was an error, but it's also in the api:

then i found the java documentation about Arbitrary Number of Arguments:

You can use a construct called varargs to pass an arbitrary number of values to a method. You use varargs when you don't know how many of a particular type of argument will be passed to the method. It's a shortcut to creating an array manually...

To use varargs, you follow the type of the last parameter by an ellipsis (three dots, ...), then a space, and the parameter name. The method can then be called with any number of that parameter, including none.

No comments:

Post a Comment