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