Integer.valueOf( int i ) vs. Integer.valueOf( String s )?
807591Apr 22 2008 — edited Apr 22 2008an inspection of the implementation ( 1.6.0_04 ) indicates that valueOf( int i ) and valueOf( String s ) differ in an interesting way.
the former attempts to return an Integer from the internal cache, while the latter always constructs a new Integer after parsing. naively, one might expect valueOf( String s ) to parse to a primitive, then invoke valueOf( int i ).
i'm guessing the original implementation is preserved to avoid breaking code that depends on unique Integer objects being returned by this method, but i'm not certain.
am i right, or is this an oversight, or am i missing something (again)?