Java Character.Subset 类



java.lang.Character.Subset 类的实例表示 Unicode 字符集的特定子集。Character 类中定义的唯一子集族是 UnicodeBlock。

类声明

以下是java.lang.Character.Subset 类的声明:

public static class Character.Subset extends Object

类构造函数

序号

构造函数及描述

1

protected Character.Subset(String name)

这将构造一个新的 Subset 实例。

Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career.

类方法

序号

方法及描述

1

equals()

此方法比较两个 Subset 对象是否相等。

2

hashCode()

此方法返回由 Object.hashCode() 方法定义的标准哈希码。

3

toString()

此方法返回此子集的名称。

比较 Subset 对象是否相等的示例

在下面的示例中,我们实例化 CharacterSubsetDemo 类对象。然后在这些对象上调用 Java Character.Subset equals() 方法来检查它们是否相等。

Open Compiler
package com.tutorialspoint; public class CharacterSubsetDemo extends Character.Subset { // constructor of super class CharacterSubsetDemo(String s) { super(s); // invokes the immediate parent class: Object } public static void main(String[] args) { CharacterSubsetDemo obj1 = new CharacterSubsetDemo("admin"); CharacterSubsetDemo obj2 = new CharacterSubsetDemo("webmaster"); CharacterSubsetDemo obj3 = new CharacterSubsetDemo("administrator"); // compares Subset objects for equality boolean retval = obj1.equals(obj1); System.out.println("Object obj1 is equal to obj1 ? " + retval); retval = obj2.equals(obj1); System.out.println("Object obj1 is equal to obj2 ? " + retval); retval = obj3.equals(obj1); System.out.println("Object obj1 is equal to obj3 ? " + retval); } }

输出

让我们编译并运行上述程序,这将产生以下结果:

Object obj1 is equal to obj1 ? true
Object obj1 is equal to obj2 ? false
Object obj1 is equal to obj3 ? false
广告