How can I call a function which accepts unknown number of String inputs (e.g. void func(String... strs)) with a given String array (String[])?
How can I call a function which accepts unknown number of String inputs (e.g.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Varargs arguments are in fact arrays. Given this method:
Calling it is simple (the following are the same):
The method implementation can then do things, such as:
Understand that varargs arguments are just syntactic sugar for call-site convenience.