- Java.lang Package classes
- Java.lang - Home
- Java.lang - Boolean
- Java.lang - Byte
- Java.lang - Character
- Java.lang - Character.Subset
- Java.lang - Character.UnicodeBlock
- Java.lang - Class
- Java.lang - ClassLoader
- Java.lang - Compiler
- Java.lang - Double
- Java.lang - Enum
- Java.lang - Float
- Java.lang - InheritableThreadLocal
- Java.lang - Integer
- Java.lang - Long
- Java.lang - Math
- Java.lang - Number
- Java.lang - Object
- Java.lang - Package
- Java.lang - Process
- Java.lang - ProcessBuilder
- Java.lang - Runtime
- Java.lang - RuntimePermission
- Java.lang - SecurityManager
- Java.lang - Short
- Java.lang - StackTraceElement
- Java.lang - StrictMath
- Java.lang - String
- Java.lang - StringBuffer
- Java.lang - StringBuilder
- Java.lang - System
- Java.lang - Thread
- Java.lang - ThreadGroup
- Java.lang - ThreadLocal
- Java.lang - Throwable
- Java.lang - Void
- Java.lang Package extras
- Java.lang - Interfaces
- Java.lang - Errors
- Java.lang - Exceptions
- Java.lang Package Useful Resources
- Java.lang - Useful Resources
- Java.lang - Discussion
Java.lang.System.identityHashCode() Method
Description
The java.lang.System.identityHashCode() method returns the same hash code for the given object as would be returned by the default method hashCode(). The hash code for the null reference is zero.
Declaration
Following is the declaration for java.lang.System.identityHashCode() method
public static int identityHashCode(Object x)
Parameters
x − This is the object for which the hashCode is to be calculated.
Return Value
This method returns the hashCode.
Exception
NA
Example
The following example shows the usage of java.lang.System.identityHashCode() method.
package com.tutorialspoint; import java.lang.*; import java.io.*; public class SystemDemo { public static void main(String[] args) throws Exception { File file1 = new File("amit"); File file2 = new File("amit"); File file3 = new File("ansh"); // returns the HashCode int ret1 = System.identityHashCode(file1); System.out.println(ret1); // returns different HashCode for same filename int ret2 = System.identityHashCode(file2); System.out.println(ret2); // returns the HashCode int ret3 = System.identityHashCode(file3); System.out.println(ret3); } }
Let us compile and run the above program, this will produce the following result −
355165777 1414159026 1569228633
java_lang_system.htm
Advertisements