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

Print this page
rev 4568 : 7088952: Add "BYTES" constant to primitive wrapper classes
7088913: Add compatible static hashCode(primitive) to primitive wrapper classes
Reviewed-by: smarks

*** 396,405 **** --- 396,417 ---- public int hashCode() { return (int)value; } /** + * Returns a hash code for a {@code short} value; compatible with + * {@code Short.hashCode()}. + * + * @since 1.8 + * + * @return a hash code value for a {@code short} value. + */ + public static int hashCode(short value) { + return (int)value; + } + + /** * Compares this object to the specified object. The result is * {@code true} if and only if the argument is not * {@code null} and is a {@code Short} object that * contains the same {@code short} value as this object. *
*** 455,464 **** --- 467,484 ---- * @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.