src/share/classes/java/lang/Boolean.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

@@ -198,10 +198,22 @@
     public int hashCode() {
         return value ? 1231 : 1237;
     }
 
     /**
+     * Returns a hash code for a {@code boolean} value; compatible with
+     * {@code Boolean.hashCode()}.
+     *
+     * @since 1.8
+     *
+     * @return a hash code value for a {@code boolean} value.
+     */
+    public static int hashCode(boolean value) {
+        return value ? 1231 : 1237;
+    }
+
+   /**
      * Returns {@code true} if and only if the argument is not
      * {@code null} and is a {@code Boolean} object that
      * represents the same {@code boolean} value as this object.
      *
      * @param   obj   the object to compare with.