I have a interface and in the interface I want to declare a method such that it can take any number of objects as input.
Something like this:
interface Implementable{
public ReturnObj doIt(objects ....);
}
Please advise
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.
The correct syntax would in your case be:
Official documentation for var-arg methods is found here.
Varargs gets compiled into an argument of an array-type. The only difference is with the vararg syntax, method calls such as
will be compiled into
In other words, given a declaration such as
you’ll have
while given the var-arg declaration, both method calls will compile and be equivalent.