I recently came across a java snippet .The function definitions have a different format than what i know till now . Following are the codes-
protected Void doInBackground(String... params) {
Log.i(TAG, "doInBackground");
//Invoke web method 'PopulateCountries' with dummy value
invokeJSONWS("dummy","PopulateCountries");
return null;
}
and a similar function with ...
in the parameter
protected void onProgressUpdate(Void... values) {
Log.i(TAG, "onProgressUpdate");
}
What does ...
mean in the following context?
Android's AsyncTask is a generic type.
When you need an async task that has no sense of intermediate progress data, you should declare it as MyTask extends AsyncTask<Something, Void, Something>
using the class Void
as the specification of the Progress
type variable, and, following usual generic rules, if you decide to overwrite onProgressUpdate
you will have to declare it as onProgressUpdate(Void... values)
.
Hence Void...
does not mean anything other than the usual vararg method whose type happened to be Void
.