prepare a set of arguments that can pass to a function in java

I want to call a function like private void passStrings(String... arg){} And I have an array which store a set of Strings but don't know its size. So How can I use all that array value and call the function passString().

Jon Skeet
people
quotationmark

Just pass it as the array:

String[] array = { "Some", "arguments", "I", "prepared", "earlier" };
passStrings(array);

A varargs parameter like arg is still an array parameter really - it's just that the compiler allows you to specify the elements individually, if you want. It doesn't force you to though - if you've already got the array, just pass it.

people

See more on this question at Stackoverflow