📜  java hashcode - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:03.063000             🧑  作者: Mango

代码示例1
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() );
   }
}