Comparing Object Values Using Hash Codes : hashCode « Class « Java






Comparing Object Values Using Hash Codes

 


import java.io.File;

public class Main {
  public static void main(String[] argv) throws Exception {
    File file1 = new File("a");
    File file2 = new File("a");
    File file3 = new File("b");

    int hc1 = file1.hashCode();
    System.out.println(hc1);
    int hc2 = file2.hashCode();
    System.out.println(hc2);
    int hc3 = file3.hashCode();
    System.out.println(hc3);
  }
}

   
  








Related examples in the same category

1.Get the identity hash codes