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 Longs

How to create Hash from Longs 

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 longs.

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

import jodd.util.HashCode;

public class HashFromLongsTest {

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

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

    hashCode = HashCode.hashLongArray(seed, 1L2L3L4L5L6L);
    System.out.println(hashCode);
    
    hashCode = HashCode.hash(seed, new long [] { 123,  456789 });
    System.out.println(hashCode);
    
    hashCode = HashCode.hash(seed, new long [] { 2,  4});
    System.out.println(hashCode);
  }

}
   

It gives the following output,
7635
1562287174
8949017
8765861



 
  


  
bl  br