The method is public static void method(Object[] params), how should I call it in the following scenarios?
- with one object as parameter
ClassA a - with more than one objects as parameters
ClassA a,ClassB b,ClassC c?
thank you
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.
You can create the array of objects on the fly:
Another suggestion is that you change the signature of the method so that it uses java varargs:
Nice thing is that it is compiled into a method with the same signature as above
(Object[] params). But it may be called likemethod(a)ormethod(a, b, c).