A DESCRIPTION OF THE REQUEST :
I request that the following convenience method is added to java.lang.String:
public static String format(Object... args) {
String.format(this, args);
}
JUSTIFICATION :
An instance-method would allow simple String formatting to be done in a more compact and readable manner.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Adding the above method to java.lang.String would allow this convenient syntax:
String s = "%1 is %2 years old".format(name, years);
... synonymous with the current ...
String s = String.format("%1 is %2 years old", name, years);
ACTUAL -
(not applicable)
---------- BEGIN SOURCE ----------
(not applicable)
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
(not applicable)
I request that the following convenience method is added to java.lang.String:
public static String format(Object... args) {
String.format(this, args);
}
JUSTIFICATION :
An instance-method would allow simple String formatting to be done in a more compact and readable manner.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Adding the above method to java.lang.String would allow this convenient syntax:
String s = "%1 is %2 years old".format(name, years);
... synonymous with the current ...
String s = String.format("%1 is %2 years old", name, years);
ACTUAL -
(not applicable)
---------- BEGIN SOURCE ----------
(not applicable)
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
(not applicable)
- duplicates
-
JDK-7056478 (str) String format method as an instance method
- Open