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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

What is happening when Matlab is starting a "parallel pool"? -