Answers for "java hashcode"

8

java hashcode

@Override
public int hashCode() {
    int hash = 7;
    hash = 31 * hash + (int) id;
    hash = 31 * hash + (name == null ? 0 : name.hashCode());
    hash = 31 * hash + (email == null ? 0 : email.hashCode());
    return hash;
}
Posted by: Guest on August-25-2020
0

java hashcode

import java.io.*;
public class IB {
 
   public static void main(String args[]) {
      String a = "100";
      String b = "100";
      if(a.equals(b))
      {
        System.out.println("Equal variables:");
        System.out.println(a.hashCode() + "\n" + b.hashCode());
      }
      
      String c = "100";
      String d = "500";
 
      if(!c.equals(d))
      {
          System.out.println("\nUn-equal variables:");
          System.out.println(c.hashCode() + "\n" + d.hashCode());
      }
      String Str = new String("We are learning hashCode in Java");
      System.out.println("Hashcode for Str :" + Str.hashCode() );
   }
}
Posted by: Guest on September-21-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language