150 |
*/ |
*/ |
151 |
public static short parseShort(String s, int radix) |
public static short parseShort(String s, int radix) |
152 |
{ |
{ |
153 |
int i = Integer.parseInt(s, radix); |
int i = Integer.parseInt(s, radix, false); |
154 |
if ((short) i != i) |
if ((short) i != i) |
155 |
throw new NumberFormatException(); |
throw new NumberFormatException(); |
156 |
return (short) i; |
return (short) i; |
209 |
* <em>DecimalDigit</em>: |
* <em>DecimalDigit</em>: |
210 |
* <em>Character.digit(d, 16) has value 0 to 15</em> |
* <em>Character.digit(d, 16) has value 0 to 15</em> |
211 |
* </pre> |
* </pre> |
212 |
* Note that you cannot decode MIN_VALUE, as the specification requires |
* Finally, the value must be in the range <code>MIN_VALUE</code> to |
213 |
* that the digits be parsed before negating the result, but 32768 will |
* <code>MAX_VALUE</code>, or an exception is thrown. |
|
* not fit in a short. |
|
214 |
* |
* |
215 |
* @param s the <code>String</code> to interpret |
* @param s the <code>String</code> to interpret |
216 |
* @return the value of the String as a <code>Short</code> |
* @return the value of the String as a <code>Short</code> |
217 |
* @throws NumberFormatException if <code>s</code> cannot be parsed as a |
* @throws NumberFormatException if <code>s</code> cannot be parsed as a |
218 |
* <code>short</code> |
* <code>short</code> |
219 |
* @throws NullPointerException if s is null |
* @throws NullPointerException if <code>s</code> is null |
220 |
* @see Integer#decode(String) |
* @see Integer#decode(String) |
221 |
*/ |
*/ |
222 |
public static Short decode(String s) |
public static Short decode(String s) |
223 |
{ |
{ |
224 |
int i = (Integer.decode(s)).intValue(); |
int i = Integer.parseInt(s, 10, true); |
225 |
if ((short) i != i) |
if ((short) i != i) |
226 |
throw new NumberFormatException(); |
throw new NumberFormatException(); |
227 |
return new Short((short) i); |
return new Short((short) i); |