java - Why is there a need of the 2 following methods in NumberFormat? -


i see numberformat has 2 methods similar:

1)

abstract number     parse(string source, parseposition parseposition) 

returns long if possible (e.g., within range [long.min_value, long.max_value] , no decimals), otherwise double.

2)

object  parseobject(string source, parseposition pos) 

parses text string produce number.

in presence of parse(s,parseindex) need of parseobject(..) needs cast desired output? aware first method throws parseexception , latter not. wondering why need of these 2 similar methods. in advance.

one of commonly heard complaints jdk why integer.parseint , similar methods cannot used validate string without involving expensive mechanism of exceptions. numberformat seems have answered complaint providing method can signal failure returning null.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -