Java.lang.Character.Subset.equals() Method


Advertisements


Description

The java.lang.Character.Subset.equals() method compares two Subset objects for equality.

Declaration

Following is the declaration for java.lang.Character.Subset.equals() method

public final boolean equals(Object obj)

Parameters

obj − This is the reference object with which to compare.

Return Value

This method returns true if this object is the same as the obj argument, else false.

Exception

NA

Example

The following example shows the usage of java.lang.Character.Subset.equals() method.

package com.tutorialspoint;

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);
   }
} 

Let us compile and run the above program, this will produce the following result −

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

java_lang_character.subset.htm

Advertisements