Aditya Jha wrote:Method format() throws exception because it expects an argument which can be cast to one of the numerical wrapper classes (or one of BigInteger, BigDecimal, AtomicInteger and AtomicLong). A string argument, even if containing only digits is bound to generate an IllegalArgumentException.
The following should work:
hi, i have checked the API:
String format(double number)
Specialization of format.
abstract StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos)
Specialization of format.
String format(long number)
Specialization of format.
abstract StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos)
Specialization of format.
StringBuffer format(Object number, StringBuffer toAppendTo, FieldPosition pos)
Formats an object to produce a string.
i cannot understand there is no one of the function above is accepting string as argument, why the compiler allow the code above to run.
Thanks.