A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.w3resource.com/java-tutorial/util/date/java_date_hashcode.php below:

Website Navigation


Java Date hashCode() Method - w3resource

Java Date.hashCode()MethodLast update on August 19 2022 21:50:42 (UTC/GMT +8 hours) public int hashCode()

The hashCode() method returns a hash code value for this object.
The result is the exclusive OR of the two halves of the primitive long value returned by the hashCode() method.
That is, the hash code is the value of the expression : (int)(this.getTime()^(this.getTime() >>> 32));

Package: java.util

Java Platform: Java SE 8

Syntax:

public int hashCode()

Return Value:
a hash code value for this object.

Return Value Type: int

Example: Java Date.hashCode() Method

import java.util.Date;
public class Main {
   public static void main(String[] args) {

      // create a date
      Date date = new Date(2017, 11, 10);

      // display the date
      System.out.println("Date: " + date.toString());

      // Print the said date using hash code and print it
      int i = date.hashCode();
      System.out.println("A hash code of the said date: " + i);
   }
}
 

Output:

Date: Mon Dec 10 00:00:00 UTC 3917
A hash code of the said date: 1436073960

Java Code Editor:

Previous:getTime Method
Next:setTime Method




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4