src/share/classes/java/lang/Short.java

Print this page
rev 6091 : 7088952: Add size in bytes constant "BYTES" to primitive type wrapper types
Summary: Adds a constant BYTES to each of the primitive wrapper classes (Byte, Character, Double, Float, Integer, Long, Short) with the calculation Primitive.SIZE / Byte.SIZE already made.
Reviewed-by: smarks, darcy

@@ -456,10 +456,18 @@
      * @since 1.5
      */
     public static final int SIZE = 16;
 
     /**
+     * The number of bytes used to represent a {@code short} value in two's
+     * complement binary form.
+     *
+     * @since 1.8
+     */
+    public static final int BYTES = SIZE / Byte.SIZE;
+
+    /**
      * Returns the value obtained by reversing the order of the bytes in the
      * two's complement representation of the specified {@code short} value.
      *
      * @return the value obtained by reversing (or, equivalently, swapping)
      *     the bytes in the specified {@code short} value.