Is there a way to define a method with an optional parameter? Or, is it
must to define the method one time with the optional parameter and
another without?
Thanks in advance,
i gues it is an old post, but I recently stumbled upon this area so wanted to share my idea:
You can always use Java option parameter expression, for example:
Code:
Public Constructor (String arg1, Int arg2, String... arg3)
You gotta remember that arg3 is expected to be an array. However, if you know that it is gonna be only one element i.e. arg3[0] you can simply do the following in your constructor definition body:
With regards to your second question, YES you can do that too. But assuming that you want a seamless interface between client and server (sorry, I am too hooked into Client-Server model) you wanna be able to keep the number of constructors to minimum. It is not a MUST for your design, but certainly a good practice.
Does this answer your question?