Duplicate :
|
|
Duplicate :
|
|
Relates :
|
A DESCRIPTION OF THE REQUEST : Byte.valueOf(byte) notes * If a new <tt>Byte</tt> instance is not required, this method * should generally be used in preference to the constructor * {@link #Byte(byte)}, as this method is likely to yield * significantly better space and time performance by caching * frequently requested values. Please provide a version of valueOf which takes a String and does the same thing. This also holds for Short, Integer and Long. JUSTIFICATION : If it is a good idea for converting byte to Byte it should also be a good idea from converting String to Byte. I understand there may be backward compatibility issues but there should be an elegant way to resolve this. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - valueOf(String) behaves in the same way as valueOf(byte) ACTUAL - valueOf(String) does the same as new Byte(String) valueOf(byte) notes that using the cache has many benifits. ---------- BEGIN SOURCE ---------- public static Byte valueOf(String s, int radix) throws NumberFormatException { return valueOf(parseByte(s, radix)); } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Call Byte.valueOf(Byte.parseByte(String)) This is tricky to do with reflections in an elegant way!
|