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

How to create Hash from Booleans 

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

File Name  :  
com/bethecoder/tutorials/jodd/hash/HashFromBooleansTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.jodd.hash;

import jodd.util.HashCode;

public class HashFromBooleansTest {

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

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

    hashCode = HashCode.hash(seed, false);
    System.out.println(hashCode);
    
    hashCode = HashCode.hash(seed, new boolean [] { true, false, true});
    System.out.println(hashCode);
    
    hashCode = HashCode.hash(seed, new boolean [] { false, true, false});
    System.out.println(hashCode);
  }

}
   

It gives the following output,
7632
7638
10495208
10503206


                    Print

   



Books Recommendation

 
 
bl  br