Java Clock class is part of Date Time API, java.time.Clock, of Java. The Java Date Time API was added from Java version 8.
hashCode() method of Clock class returns the hash code for this Clock Object. Clocks object overrides this method based on their state. If clock object is not overridden, the behaviour of this method is defined by Object.hashCode(). The hashcode is always the same if the object doesn’t change.
Hashcode is a unique code generated by the JVM at time of object creation. It can be used to perform some operation on hashing related algorithm like hashtable, hashmap etc. An object can also be searched with its unique code (hashcode).
public int hashCode()
Returns: This method returns a suitable hash code for this clock Method.
Input:: a clock class Object e.g Clock.systemDefaultZone() Output:: HashCode e.g. 227139178 Explanation:: when hashCode() is called, then it will return a hashCode for Class Object.
Below programs illustrates hashCode() method of java.time.Clock class:
Program 1: Clock obejct is created with systemDefaultZone and using hashCode() of Clock object get the hash Code and print it.
hash Code for class SystemClock[Etc/UTC] is 227139178
Program 2: Get HashCode of Clock object with Zone “Asia/calcutta” using hashCode()
hashCode for clock object SystemClock[Asia/Calcutta] is -681304889
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- Android | How to display Analog clock and Digital clock
- Java Clock tickMinutes() method in Java with Examples
- Java Clock withZone() method in Java with Examples
- Java 8 Clock instant() method with Examples
- Java 8 Clock getZone() method with Examples
- Java 8 Clock fixed() method with Examples
- Java 8 Clock millis() Method with Examples
- Java 8 Clock equals() Method with Examples
- Java 8 Clock offset() method with Examples
- Clock tick() Method in Java with Examples
- Clock tickSeconds() method in Java with Examples
- Clock systemDefaultZone() Method in Java with Examples
- Clock systemUTC() Method in Java with Examples
- Clock system() Method in Java with Examples
- JapaneseDate now(Clock) method in Java with Examples
- YearMonth now(clock) method in Java with Examples
- LocalTime now(clock) method in Java with Examples
- MonthDay now(Clock) method in Java with Examples
- Boolean hashCode() method in Java with examples
- Byte 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 email@example.com. 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.