In C/C++, the number of parameters in a function can be variable, I don't see any similiar feature in Java. So how can I implement it in Java?
Thanks,
Laurence
Printable View
In C/C++, the number of parameters in a function can be variable, I don't see any similiar feature in Java. So how can I implement it in Java?
Thanks,
Laurence
That functionality in Java does not exist. You could create multiple overloaded methods, but that would stilll require you to manually code them. The only option you really have for passing an unspecified number of parameters to a method is by using a Vector (if you're using multiple class types), or an array of the specified type, and then parsing the vector/array from within the method.