1
vote
1answer
68 views

Guava Optional as method argument for optional parameters

Recently I had a discussion with my teammate on use of Guava Optional for optional parameters in a method. Let's say method is List<Book> getBooks(String catalogId, Optional<String> ...
0
votes
1answer
509 views

Implementing a Stored Procedure Call with Optional Parameters in Spring 3.0

I've been trying to find a way to make stored proc calls from Spring 3.0 to Oracle 11.2 with following the items in mind: Many of the calls are made to stored procedures that have plethora of ...
2
votes
3answers
47 views

java: C-like option parameters

I'm making this utility class and I want to make it able to pass additional options to my methods: import java.util.Random; public class DataGen { public static final int OPTION1 = 1; public ...
1
vote
2answers
63 views

copy constructor in java

class Client{ private String name; private int age; private int amount; public Client(Client otherClient){ name=otherClient.name; age=otherClient.age; amount=otherClient.amount; } } ...
2
votes
4answers
121 views

Have multiple optional parameters

I am trying to have optional parameters in my method. I found the bolean... test, and it works. But whenever I try with a sencond one, it doesn't work. Is there a possibility to put two or more (of ...
1
vote
2answers
95 views

How to define user defined java runtime optional command line arguments [closed]

Instead of giving parameters to my java program in run time with java myprogram "Analyse_Dnase" "Analyse_Histone" "Analyse_Tf" "Analyse_Gene" "Not_Analyse_Kegg_Pathway" I want to give parameters to ...
0
votes
4answers
321 views

What is the difference between “…” and “[]” in Android Java function parameters? [duplicate]

I saw examples where one puts an array parameter to a function like this : function f(String... strings) { } and I guess this is one way of saying "expect an indefinite number of strings". But ...
1
vote
2answers
75 views

What's the best design when adding in optional parameters in languages that don't support it?

Say I have void foo(int a); and I want to add in an optional parameter using a language that doesn't support it (i.e. Java): void foo(int a, int optionalParam); Lets say I'll set the default to ...
0
votes
0answers
123 views

Java MessageFormat resource with optional parameter?

Is it possible to have an optional parameter to a message format? I have code that history for something with an event type and parameters encoded as strings. This gets loaded by other code and does ...
1
vote
1answer
94 views

When overloading methods in Java, where do you calculate aditional parameter data?

I often find myself in situations where I have a method signature like this: public returnType doStuff(mandatoryParam, calculableParam1, calculableParam2); In these situations I sometimes want to ...
0
votes
1answer
366 views

Optional Parameters in MAIN() for JAVA

Is it possible to implement optional parameters for a Java program? I tried searching this up, but all that came up was for overloading methods in Java, not specifically the main(). What I'm trying ...
1
vote
4answers
539 views

Optional Anonymous Parameters Passing in Java

I have two classes A and B. A has a method, say foo, that can have any number of parameters of any types. This method relays these parameters to a method with predetermined number of params of ...
1
vote
1answer
361 views

Documenting Varargs Appropriately for Javadoc

I'm using varargs in a method for optional parameters. Any suggestion for how best to document the method? Here's a wonderfully contrived example: /** * * @param consumption * liters of liquid ...
1
vote
3answers
2k views

Java varargs for multiple arguments

Is it considered a good programing idiom to use Java varargs as an optional parameter? Even more: if I have an interface, and some implementations need the additional parameter, and some don't, is it ...
2
votes
1answer
611 views

How to call method with optional parameter list in JSF2 / EL 2.2

any idea how (if even possible) to call java method with optional parameters from JSF page? Iam using Java 7,JSF 2.1, EL 2.2 (Glassfish 3.1.2). Thanks in advance... I got this exception ...
0
votes
1answer
223 views

VB.NET -v- Java: Switch statements & optional parameters

Is there an equivalent in Java to VB.NET's optional parameters? Also is it possible to switch on anything other than integers in Java? Thanks.
1
vote
3answers
193 views

Java Associative Array as Options for Method

I am re-learning Java after having an affair with PHP for some years, and I have a question about a convention used in PHP, and how I would accomplish a similar goal in Java... PHP function ...
1
vote
4answers
938 views

Adding parameters to Runtime.getRuntime()?

void restartWeb() { try { String[] command = new String[] {"webRestarter.exe" , ">>","webLog.log"}; Runtime.getRuntime().exec(command); } catch ...
13
votes
6answers
6k views

Why optional parameters must appear at the end of the declaration

In all programming languages supporting optional parameters that I have seen there is a imitation that the optional parameters must appear at the end of the declaration. No required parameters may be ...
3
votes
2answers
2k views

Which is the better way to simulate optional parameters in Java?

I have a Java method that takes 3 parameters, and I'd like it to also have a 4th "optional" parameter. I know that Java doesn't support optional parameters directly, so I coded in a 4th parameter and ...
4
votes
4answers
8k views

java optional parameters

I want to write an average method in java such that it can consume N amount of items, returning the average of them: My idea was: public static int average(int[] args){ int total = 0; ...
190
votes
10answers
243k views

Java optional parameters

How do I use optional parameters in Java? What specification supports optional parameters?
4
votes
2answers
1k views

Optional Parameter in MVEL Functions

Is there a way to get MVEL 2.0 ( http://mvel.codehaus.org/ ) to work with functions with optional parameters? I would like to be able to eval this: trunc('blahblah',2) but also ...