Boolean hashCode() method in Java with examples
The hashCode() method of Boolean class is a built in method to return a int hashcode value corresponding to the Boolean object.
Syntax
BooleanObject.hashCode()
Return Type: It returns a int hashcode value corresponding to the Boolean object. It returns 1231 if the Boolean object stores the value true. It returns 1237 if the Boolean object stores the value false.
Below is the implementation of hashCode() method in Java:
Program 1:
// java code to demonstrate // Boolean hashCode() method class GFG { public static void main(String[] args) { // creating Boolean object Boolean b = new Boolean(true); // hashCode method of Boolean class int output = b.hashCode(); // printing the output System.out.println(output); } } |
1231
Program 2:
// java code to demonstrate // Boolean hashCode() method class GFG { public static void main(String[] args) { // creating Boolean object Boolean b = new Boolean(false); // hashCode method of Boolean class int output = b.hashCode(); // printing the output System.out.println(output); } } |
1237
Recommended Posts:
- Java Guava | Booleans.indexOf(boolean[] array, boolean[] target) method with Examples
- Java Guava | Booleans.indexOf(boolean[] array, boolean target) method with Examples
- Map hashCode() Method in Java with Examples
- Set hashCode() method in Java with Examples
- DecimalFormatSymbols hashCode() method in Java with Examples
- Duration hashCode() method in Java with Examples
- Byte hashCode() method in Java with examples
- UUID hashCode() Method in Java with Examples
- Optional hashCode() method in Java with examples
- AbstractMap hashCode() Method in Java with Examples
- Locale hashCode() Method in Java with Examples
- AbstractList hashCode() method in Java with Examples
- BitSet hashCode Method in Java with Examples
- MonthDay hashCode() method in Java with Examples
- OptionalLong hashCode() method in Java with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



