I am preparing for SCJP and I came to know Methods with variable argument list. I have couple questions.
- What is “Methods with variable argument list”.
- When to use “Methods with variable argument list”.
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.
Its a language feature that allows you to declare a method that will take any number of arguments.
Accordingly, you use it when you don’t/can’t know how many arguments you will pass to the method. Look at the String.format method. In the method declaration, the final parameter is
Object... argswhich indicates that format can take any number of arguments.See also this: http://download.oracle.com/javase/1,5.0/docs/guide/language/varargs.html