What is the difference between String and String... and what is the difference between Void and Void... in this context?
class AddStringsTask extends AsyncTask<Void, String, Void>{
@Override
protected Void doInBackground(Void... unused) {
for (String item: items){
publishProgress(item);
SystemClock.sleep(200);
}
return(null);
}
@Override
protected void onProgressUpdate(String... item){
((ArrayAdapter)getListAdapter()).add(item[0]);
}
@Override
protected void onPostExecute(Void unused){
Toast.makeText(Cap15Asyncer.this,"Completed!" , Toast.LENGTH_SHORT).show();
}
}
In the method
String... itemMeans that the method takes an arbitrary number of Strings (including 0 Strings). So this method can be called with any number of strings as input, and it will add them all to the listAdapter, like an array. If the method was:Then it would take exactly one String, (note the add method has changed accordingly).