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 -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -