tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Google Guava > Basic > Multi Object Hashcode

Multi Object Hashcode 

Google Guava is a java library with lot of utilities and reusable components. This requires the library guava-10.0.jar to be in classpath. The following example shows using Objects.hashCode() API. It returns has code for the given objects.

File Name  :  
Author  :  Sudhakar KV
Email  :  [email protected]
package com.bethecoder.tutorials.guava.base_tests;

import com.bethecoder.tutorials.guava.common.Student;

public class HashCodeTest {

   @param args
  public static void main(String[] args) {
    Student student = new Student("Sriram"2"Chess");
    Student student2 = new Student("Sudhakar"29"Painting");
    int hashCode = Objects.hashCode(student, student2)//Internally uses Arrays.hashCode
    System.out.println("Hash code : " + hashCode);


It gives the following output,
Hash code : 300327489



Books Recommendation

Your Ad Here
bl  br