src/share/classes/java/lang/Integer.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
*** 754,763 ****
--- 754,775 ----
public int hashCode() {
return value;
}
/**
+ * Returns a hash code for a {@code int} value; compatible with
+ * {@code Integer.hashCode()}.
+ *
+ * @since 1.8
+ *
+ * @return a hash code value for a {@code int} value.
+ */
+ public static int hashCode(int value) {
+ return 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 an {@code Integer} object that
* contains the same {@code int} value as this object.
*
*** 1033,1042 ****
--- 1045,1062 ----
* @since 1.5
*/
public static final int SIZE = 32;
/**
+ * The number of bytes used to represent a {@code int} value in two's
+ * complement binary form.
+ *
+ * @since 1.8
+ */
+ public static final int BYTES = SIZE / Byte.SIZE;
+
+ /**
* Returns an {@code int} value with at most a single one-bit, in the
* position of the highest-order ("leftmost") one-bit in the specified
* {@code int} value. Returns zero if the specified value has no
* one-bits in its two's complement binary representation, that is, if it
* is equal to zero.