Java Character.SubSet equals()方法
java.lang.Character.SubSet.equals() 方法比较两个子集相等对的对象。
1 语法
public final boolean equals(Object obj)
2 参数
obj:这是要与之比较的引用对象。
3 返回值
如果这个对象与obj参数是一样的此方法返回true,否则返回false。
4 示例
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
/**
* Java Character.SubSet equals()方法
*/
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
热门文章
优秀文章