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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -