285 int i = Integer.decode(nm);
286 if (i < MIN_VALUE || i > MAX_VALUE)
287 throw new NumberFormatException(
288 "Value " + i + " out of range from input " + nm);
289 return valueOf((short)i);
290 }
291
292 /**
293 * The value of the {@code Short}.
294 *
295 * @serial
296 */
297 private final short value;
298
299 /**
300 * Constructs a newly allocated {@code Short} object that
301 * represents the specified {@code short} value.
302 *
303 * @param value the value to be represented by the
304 * {@code Short}.
305 */
306 public Short(short value) {
307 this.value = value;
308 }
309
310 /**
311 * Constructs a newly allocated {@code Short} object that
312 * represents the {@code short} value indicated by the
313 * {@code String} parameter. The string is converted to a
314 * {@code short} value in exactly the manner used by the
315 * {@code parseShort} method for radix 10.
316 *
317 * @param s the {@code String} to be converted to a
318 * {@code Short}
319 * @throws NumberFormatException If the {@code String}
320 * does not contain a parsable {@code short}.
321 * @see java.lang.Short#parseShort(java.lang.String, int)
322 */
323 public Short(String s) throws NumberFormatException {
324 this.value = parseShort(s, 10);
325 }
326
327 /**
328 * Returns the value of this {@code Short} as a {@code byte} after
329 * a narrowing primitive conversion.
330 * @jls 5.1.3 Narrowing Primitive Conversions
331 */
332 public byte byteValue() {
333 return (byte)value;
334 }
335
336 /**
337 * Returns the value of this {@code Short} as a
338 * {@code short}.
339 */
340 @HotSpotIntrinsicCandidate
341 public short shortValue() {
342 return value;
|
285 int i = Integer.decode(nm);
286 if (i < MIN_VALUE || i > MAX_VALUE)
287 throw new NumberFormatException(
288 "Value " + i + " out of range from input " + nm);
289 return valueOf((short)i);
290 }
291
292 /**
293 * The value of the {@code Short}.
294 *
295 * @serial
296 */
297 private final short value;
298
299 /**
300 * Constructs a newly allocated {@code Short} object that
301 * represents the specified {@code short} value.
302 *
303 * @param value the value to be represented by the
304 * {@code Short}.
305 *
306 * @deprecated
307 * It is rarely appropriate to use this constructor. The static factory
308 * {@link #valueOf(short)} is generally a better choice, as it is
309 * likely to yield significantly better space and time performance.
310 */
311 @Deprecated(since="9")
312 public Short(short value) {
313 this.value = value;
314 }
315
316 /**
317 * Constructs a newly allocated {@code Short} object that
318 * represents the {@code short} value indicated by the
319 * {@code String} parameter. The string is converted to a
320 * {@code short} value in exactly the manner used by the
321 * {@code parseShort} method for radix 10.
322 *
323 * @param s the {@code String} to be converted to a
324 * {@code Short}
325 * @throws NumberFormatException If the {@code String}
326 * does not contain a parsable {@code short}.
327 *
328 * @deprecated
329 * It is rarely appropriate to use this constructor.
330 * Use {@link #parseShort(String)} to convert a string to a
331 * {@code short} primitive, or use {@link #valueOf(String)}
332 * to convert a string to a {@code Short} object.
333 */
334 @Deprecated(since="9")
335 public Short(String s) throws NumberFormatException {
336 this.value = parseShort(s, 10);
337 }
338
339 /**
340 * Returns the value of this {@code Short} as a {@code byte} after
341 * a narrowing primitive conversion.
342 * @jls 5.1.3 Narrowing Primitive Conversions
343 */
344 public byte byteValue() {
345 return (byte)value;
346 }
347
348 /**
349 * Returns the value of this {@code Short} as a
350 * {@code short}.
351 */
352 @HotSpotIntrinsicCandidate
353 public short shortValue() {
354 return value;
|