WeekFields hashCode() method in Java with Examples
The hashCode() method of WeekFields class is used to return the hash code for this WeekFields.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 integer value which is the hashCode value.
Below programs illustrate the WeekFields.hashCode() method:
Program 1:
import java.time.DayOfWeek;
import java.time.temporal.WeekFields;
public class GFG {
public static void main(String[] args)
{
WeekFields weekFields
= WeekFields.of(DayOfWeek.MONDAY, 1 );
int hashCode = weekFields.hashCode();
System.out.println( "Hash Code:"
+ hashCode);
}
}
|
Program 2:
import java.time.DayOfWeek;
import java.time.temporal.WeekFields;
import java.util.Locale;
public class GFG {
public static void main(String[] args)
{
Locale locale = new Locale( "EN" , "US" );
WeekFields weekFields
= WeekFields.of(locale);
int hashCode = weekFields.hashCode();
System.out.println( "Hash Code:"
+ hashCode);
}
}
|
References: https://docs.oracle.com/javase/10/docs/api/java/time/temporal/WeekFields.html#hashCode()
Last Updated :
29 Jan, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...