< prev index next >

src/java.base/share/classes/java/lang/Byte.java

Print this page
rev 14117 : 8145468: update java.lang APIs with new deprecations
Reviewed-by: XXX


 280         int i = Integer.decode(nm);
 281         if (i < MIN_VALUE || i > MAX_VALUE)
 282             throw new NumberFormatException(
 283                     "Value " + i + " out of range from input " + nm);
 284         return valueOf((byte)i);
 285     }
 286 
 287     /**
 288      * The value of the {@code Byte}.
 289      *
 290      * @serial
 291      */
 292     private final byte value;
 293 
 294     /**
 295      * Constructs a newly allocated {@code Byte} object that
 296      * represents the specified {@code byte} value.
 297      *
 298      * @param value     the value to be represented by the
 299      *                  {@code Byte}.





 300      */

 301     public Byte(byte value) {
 302         this.value = value;
 303     }
 304 
 305     /**
 306      * Constructs a newly allocated {@code Byte} object that
 307      * represents the {@code byte} value indicated by the
 308      * {@code String} parameter. The string is converted to a
 309      * {@code byte} value in exactly the manner used by the
 310      * {@code parseByte} method for radix 10.
 311      *
 312      * @param s         the {@code String} to be converted to a
 313      *                  {@code Byte}
 314      * @throws           NumberFormatException If the {@code String}
 315      *                  does not contain a parsable {@code byte}.
 316      * @see        java.lang.Byte#parseByte(java.lang.String, int)





 317      */

 318     public Byte(String s) throws NumberFormatException {
 319         this.value = parseByte(s, 10);
 320     }
 321 
 322     /**
 323      * Returns the value of this {@code Byte} as a
 324      * {@code byte}.
 325      */
 326     @HotSpotIntrinsicCandidate
 327     public byte byteValue() {
 328         return value;
 329     }
 330 
 331     /**
 332      * Returns the value of this {@code Byte} as a {@code short} after
 333      * a widening primitive conversion.
 334      * @jls 5.1.2 Widening Primitive Conversions
 335      */
 336     public short shortValue() {
 337         return (short)value;




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


< prev index next >