Java/Class/hashCode
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);
}
}
Get the identity 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 ihc1 = System.identityHashCode(file1);
System.out.println(ihc1);
int ihc2 = System.identityHashCode(file2);
System.out.println(ihc2);
int ihc3 = System.identityHashCode(file3);
System.out.println(ihc3);
}
}