- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java 8 Clock hashCode() method
The hash code for a clock object can be obtained using the method hashCode() in the Clock Class in Java. This method requires no parameters and it returns the acceptable hash code for a clock object.
A program that demonstrates this is given as follows −
Example
import java.time.*; public class Demo { public static void main(String[] args) { Clock c = Clock.systemDefaultZone(); int hashCode = c.hashCode(); System.out.println("The clock is: " + c); System.out.println("The hash code is: " + hashCode); } }
Output
The clock is: SystemClock[Etc/UTC] The hash code is: 227139178
Now let us understand the above program.
The hash code for the specified clock object is obtained using the method hashCode() and then this value is displayed. A code snippet that demonstrates this is as follows −
Clock c = Clock.systemDefaultZone(); int hashCode = c.hashCode(); System.out.println("The clock is: " + c); System.out.println("The hash code is: " + hashCode);
Advertisements