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