日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

Java System类identityHashCode()方法及示例

發(fā)布時間:2025/3/11 java 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Java System类identityHashCode()方法及示例 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

系統(tǒng)類identityHashCode()方法 (System class identityHashCode() method)

  • identityHashCode() method is available in java.lang package.

    identityHashCode()方法在java.lang包中可用。

  • identityHashCode() method is used to return the hashcode of the given object – By using this method the value of hashcode will be the same as the value of hashcode by using hashCode() method.

    identityHashCode()方法用于返回給定對象的哈希碼–通過使用此方法,哈希碼的值將與使用hashCode()方法的哈希碼的值相同。

  • Let suppose, if we pass an object that holds null value then in that case, the value of hashCode will be 0.

    假設(shè),如果我們傳遞一個持有null值的對象,則在這種情況下,hashCode的值將為0 。

  • identityHashCode() method is a static method so this method is accessible with the class name too.

    identityHashCode()方法是靜態(tài)方法,因此也可以使用類名訪問此方法。

  • identityHashCode() method does not throw any exception.

    identityHashCode()方法不會引發(fā)任何異常。

Syntax:

句法:

public static int identityHashCode(Object obj);

Parameter(s):

參數(shù):

  • obj – represent the object for which the hashcode is to be returned.

    obj –代表要為其返回哈希碼的對象。

Return value:

返回值:

The return type of this method is int, it returns the hashcode of the given argument.

此方法的返回類型為int ,它返回給定參數(shù)的哈希碼。

Example:

例:

// Java program to demonstrate the example of // identityHashCode () method of System Classimport java.lang.*; import java.io.*;public class IdentityHashCodeMethod {public static void main(String[] args) throws Exception {File file1 = new File("Java");File file2 = new File("Programming");// getting hashcodeint hcode1 = System.identityHashCode(file1);System.out.println(hcode1);// getting hashcodeint hcode2 = System.identityHashCode(file2);System.out.println(hcode2);} }

Output

輸出量

E:\Programs>javac IdentityHashCodeMethod.java E:\Programs>java IdentityHashCodeMethod 1018081122 242131142

翻譯自: https://www.includehelp.com/java/system-class-identityhashcode-method-with-example.aspx

總結(jié)

以上是生活随笔為你收集整理的Java System类identityHashCode()方法及示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。