Java Boolean类中hashCode()方法具有什么功能呢?
下文笔者将讲述Boolean类中hashCode()方法的功能简介说明,如下所示:
java.lang.Boolean.hashCode方法的示例分享
java.lang.Boolean.hashCode方法简介
java.lang.Boolean.hashCode的功能:
Boolean对象的哈希码
java.lang.Boolean.hashCode的语法:
public int hashCode()
----参数值说明----
无
返回值说明
当返回值为1231 时,则表示对象为true
当返回值为1237 时,则表示对象为false
注意事项:
当Boolean对象为null时,hashCode方法将无法通过编译
例:java.lang.Boolean.hashCode方法的示例分享
package com.java.other;
import org.junit.Test;
public class other {
/**
* java265.com 测试示例分享
*/
@Test
public void test() {
/**
* Boolean类 hashCode方法的示例
*/
Boolean b1 = true;
Boolean b2 = false;
System.out.println(b1.hashCode());
System.out.println(b2.hashCode());
}
}
-------运行以上代码,将输出以下信息----
1231
1237
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。


