ValueRange hashCode() method in Java with Examples
The hashCode() method of ValueRange class is used to get the hashCode value for this ValueRange. It returns an integer value which is the hashCode value for this instance of the ValueRange.
Syntax:
public int hashCode()
Parameters:
This method accepts nothing.
Return value:
This method returns a suitable hash code.
Below programs illustrate the ValueRange.hashCode() method:
Program 1:
import java.time.LocalDateTime;
import java.time.temporal.ChronoField;
import java.time.temporal.ValueRange;
public class GFG {
public static void main(String[] args)
{
LocalDateTime l1
= LocalDateTime
.parse( "2018-02-06T19:21:12" );
ValueRange vR
= l1.range(ChronoField.DAY_OF_MONTH);
int code = vR.hashCode();
System.out.println( "hashCode: "
+ code);
}
}
|
Output:
hashCode: 1900573
Program 2:
import java.time.temporal.ValueRange;
public class GFG {
public static void main(String[] args)
{
ValueRange vRange = ValueRange.of( 1111 , 66666 );
int code = vRange.hashCode();
System.out.println( "hashCode: "
+ code);
}
}
|
Output:
hashCode: 3932210
References: https://docs.oracle.com/javase/10/docs/api/java/time/temporal/ValueRange.html#hashCode()
Last Updated :
29 Jan, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...