-
Enhancement
-
Resolution: Not an Issue
-
P4
-
None
-
1.4.2, 6
-
x86
-
linux, windows_xp
Name: rmT116609 Date: 10/20/2003
A DESCRIPTION OF THE REQUEST :
Java forces me to supply an argument for each method parameter.
JUSTIFICATION :
Lengthy method signatures often require convenience overloads that supply the requisite default values. These methods cut down on clutter and errors in the caller's code. Overriding them is a pain, however, and you can often end up with one additional method for each parameter.
public void foo( boolean a)...
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
public void foo(boolean a = true, String b = "bar", Long c = 1, double d = 1.0)
ACTUAL -
Obviously this will not compile because Java does not allow default arguments.
---------- BEGIN SOURCE ----------
Not applicable: language extension required to fix this.
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
public void foo( boolean a, String b, Long c, double d)...
public void foo( boolean a, String b, Long c)...
public void foo( boolean a, String b)...
Supply a convenience method for each permutation (or is that combination) of parameters.
(Incident Review ID: 216646)
======================================================================
A DESCRIPTION OF THE REQUEST :
Java forces me to supply an argument for each method parameter.
JUSTIFICATION :
Lengthy method signatures often require convenience overloads that supply the requisite default values. These methods cut down on clutter and errors in the caller's code. Overriding them is a pain, however, and you can often end up with one additional method for each parameter.
public void foo( boolean a)...
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
public void foo(boolean a = true, String b = "bar", Long c = 1, double d = 1.0)
ACTUAL -
Obviously this will not compile because Java does not allow default arguments.
---------- BEGIN SOURCE ----------
Not applicable: language extension required to fix this.
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
public void foo( boolean a, String b, Long c, double d)...
public void foo( boolean a, String b, Long c)...
public void foo( boolean a, String b)...
Supply a convenience method for each permutation (or is that combination) of parameters.
(Incident Review ID: 216646)
======================================================================
- duplicates
-
JDK-8154512 Optional parameters
-
- Closed
-
-
JDK-8019620 Support for default values in constructor/method parameters
-
- Closed
-
- relates to
-
JDK-6356761 Parameters declaration improvement using annotations
-
- Closed
-