> Excuse my ignorance - I'm coming from the other development environment :(
> Is there a way to specify a function parameter as being optional? I
> know C++ has them, and PHP parameters are all optional, but I can't find
> anything about it in Java. Thanks in advance.
>
> Tom
You can provide two or more method declarations with the same name but
different parameter lists.
Often, the ones with the shorter lists just call the full version with
default values of the missing parameters, and only the full version has
a non-trivial implementation.
See, for example, the indexOf methods in String. The fromIndex
parameters can be thought of as being optional parameters, although
there are actually separate method declarations with and without them.
Patricia
tomb - 17 Sep 2006 19:06 GMT
Thank you :)
Tom
>> Excuse my ignorance - I'm coming from the other development
>> environment :(
[quoted text clipped - 16 lines]
>
> Patricia
Ian Shef - 18 Sep 2006 20:59 GMT
Patricia Shanahan <pats@acm.org> wrote in news:HjdPg.2625$UG4.1603
@newsread2.news.pas.earthlink.net:
>> Excuse my ignorance - I'm coming from the other development environment :(
>> Is there a way to specify a function parameter as being optional? I
[quoted text clipped - 5 lines]
> You can provide two or more method declarations with the same name but
> different parameter lists.
<snip>
> Patricia
Starting in Java 1.5, of course, there is also the varargs feature. See for
example:
http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html
http://java.sun.com/developer/JDCTechTips/2005/tt0104.html#1
To be used sparingly and appropriately as these articles point out.

Signature
Ian Shef 805/F6 * These are my personal opinions
Raytheon Company * and not those of my employer.
PO Box 11337 *
Tucson, AZ 85734-1337 *