Boolean hashCode() method in Java with examples
Last Updated :
08 Oct, 2018
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:
class GFG {
public static void main(String[] args)
{
Boolean b = new Boolean( true );
int output = b.hashCode();
System.out.println(output);
}
}
|
Program 2:
class GFG {
public static void main(String[] args)
{
Boolean b = new Boolean( false );
int output = b.hashCode();
System.out.println(output);
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...