Java Date Time - Clock hashCode() example








Clock hashCode() returns the hash code for this clock.

Syntax

hashCode has the following syntax.

public int hashCode()

Example

The following example shows how to use hashCode.

import java.time.Clock;
/*from   w  ww. j av  a 2 s  .  c  o  m*/
public class Main {
  public static void main(String[] args) {
    Clock clock = Clock.systemUTC();
    Clock clock1 = Clock.systemDefaultZone();
    System.out.println(clock.hashCode());
    System.out.println(clock1.hashCode());
  }
}

The code above generates the following result.