博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java System类identityHashCode()方法及示例
阅读量:2531 次
发布时间:2019-05-11

本文共 1796 字,大约阅读时间需要 5 分钟。

系统类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.

    假设,如果我们传递一个持有null值的对象,则在这种情况下,hashCode的值将为0

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

    identityHashCode()方法是静态方法,因此也可以使用类名访问此方法。

  • identityHashCode() method does not throw any exception.

    identityHashCode()方法不会引发任何异常。

Syntax:

句法:

public static int identityHashCode(Object obj);

Parameter(s):

参数:

  • 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 ,它返回给定参数的哈希码。

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 hashcode int hcode1 = System.identityHashCode(file1); System.out.println(hcode1); // getting hashcode int hcode2 = System.identityHashCode(file2); System.out.println(hcode2); }}

Output

输出量

E:\Programs>javac IdentityHashCodeMethod.javaE:\Programs>java IdentityHashCodeMethod1018081122242131142

翻译自:

转载地址:http://odtzd.baihongyu.com/

你可能感兴趣的文章
JavaBean规范
查看>>
第四阶段 15_Linux tomcat安装与配置
查看>>
NAS 创建大文件
查看>>
学习笔记-模块之xml文件处理
查看>>
简单的栈和队列
查看>>
接口测试用例
查看>>
面试:用 Java 实现一个 Singleton 模式
查看>>
Sybase IQ导出文件的几种方式
查看>>
案例:手动输入一个字符串,打散放进一个列表,小写字母反序 大写字母保持不变...
查看>>
点语法
查看>>
IO之Socket网络编程
查看>>
PCRE demo【转】
查看>>
矩阵的SVD分解
查看>>
gitlab的配置
查看>>
linux访问ftp服务器命令
查看>>
ActiveMQ学习笔记之异常
查看>>
LuoguP4012 深海机器人问题(费用流)
查看>>
自动机
查看>>
java知识点
查看>>
WPF设计の画刷(Brush)
查看>>