File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Does Java offer any support for optional/default parameters? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Does Java offer any support for optional/default parameters?" Watch "Does Java offer any support for optional/default parameters?" New topic
Author

Does Java offer any support for optional/default parameters?

Michael Arnett
Ranch Hand

Joined: Mar 22, 2001
Posts: 65
Hi!
I was wondering if Java had any method for supporting optional parameters? I know about the ability to overload, but is there any default value methodology, outright optional parameter syntax, etc.? Thanks in advance!
-MLA

Sun Certified Programmer for the Java 2 Platform 1.4
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
Only overloading. Java didn't have default parameters like VB and some other languages. You can mimic it using :


------------------
Hope This Helps
Carl Trusiak, SCJP2
[This message has been edited by Carl Trusiak (edited May 25, 2001).]


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Could you also mimic this by making one of the parameters an array of objects? This way you can supply any number of parameters.
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
yes , if you don't wish to pass an array to that method you can pass a null to it which your method would handle depedning on logic of it.


Val SCJP <BR>going for SCJD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Does Java offer any support for optional/default parameters?