java.lang.Character.Subset.equals()方法实例
java.lang.Character.Subset.equals() 方法比较两个子集相等对的对象。
声明
以下是java.lang.Character.Subset.equals()方法的声明
public final boolean equals(Object obj)
参数
-
obj -- 这是要与之比较的引用对象。
返回值
如果这个对象与obj参数是一样的此方法返回true,否则返回false。
异常
-
NA
例子
下面的例子显示java.lang.Character.Subset.equals()方法的使用。
package com.yiibai; import java.lang.*; public class CharacterSubsetDemo extends Character.Subset { // constructor of super class CharacterSubsetDemo(String s){ super(s); } 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