java - What significance does `...` serve following a parameter type? -
this question has answer here:
- java, 3 dots in parameters 8 answers
i trying asynctasks working in android, , have found have never seen before on , on again in many different tutorials.
certain methods in tutorials passed parameters string... arg0
, integer... values
.
here
tutorial code shown similar describing.
what mean? why ...
there?
it called varargs. works type long it's last argument in signature.
basically, number of parameters put array. not mean equivalent array.
a method looks like:
void foo(int bar, socket baz...)
will have array of socket (in example) called baz.
so, if call foo(32, ssock.accept(), new socket())
we'll find array 2 socket objects.
calling foo(32, mysocketarray)
not work. however, if signature varargs of arrays can pass 1 or more arrays , two-dimensional array. example, void bar(int bar, printstream[] baz...)
can take multiple arrays of printstream , stick them single printstream[][]
.
Comments
Post a Comment