prepare a set of arguments that can pass to a function in java -
this question has answer here:
i want call function private void passstrings(string... arg){}
, have array store set of strings don't know size. how can use array value , call function passstring().
just pass as array:
string[] array = { "some", "arguments", "i", "prepared", "earlier" }; passstrings(array);
a varargs parameter arg
still array parameter - it's compiler allows specify elements individually, if want. doesn't force though - if you've got array, pass it.
Comments
Post a Comment