tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Jodd > Commons > How to create Hash from Doubles

How to create Hash from Doubles 

Jodd is an open-source java library with lot of reusable components and feature rich utilities. This requires the library jodd-3.3.2.jar to be in classpath. The following example shows how to use HashCode.hash() API. It calculates the hash code from the given doubles.

File Name  :  
com/bethecoder/tutorials/jodd/hash/HashFromDoublesTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.jodd.hash;

import jodd.util.HashCode;

public class HashFromDoublesTest {

  /**
   @param args
   */
  public static void main(String[] args) {

    int seed = HashCode.SEED;
    int hashCode = HashCode.hash(seed, 1234.56);
    System.out.println(hashCode);

    hashCode = HashCode.hashDoubleArray(seed, 1.1112.2223.333);
    System.out.println(hashCode);
    
    hashCode = HashCode.hash(seed, new double [] { 1.23,  45.67.89 });
    System.out.println(hashCode);
    
    hashCode = HashCode.hash(seed, new double [] { 2.3,  4.56.789 });
    System.out.println(hashCode);
  }

}
   

It gives the following output,
808498744
-1652300028
461760507
1837941050



 
  


  
bl  br