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

Advertisements


Description

The java.lang.Character.Subset.hashCode() method returns the standard hash code.

Declaration

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

public final int hashCode()

Parameters

  • NA

Return Value

This method returns a hash code value for this object.

Exception

  • NA

Example

The following example shows the usage of java.lang.Character.Subset.hashCode() 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");

      // returns a hash code value
      int retval = obj1.hashCode();
      System.out.println("Hash code of Object " + obj1 + " = " + retval);
      retval = obj2.hashCode();
      System.out.println("Hash code of Object " + obj2 + " = " + retval);
      retval = obj3.hashCode();
      System.out.println("Hash code of Object " + obj3 + " = " + retval);
   }
} 

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

Hash code of Object admin = 1414159026
Hash code of Object webmaster = 1569228633
Hash code of Object administrator = 778966024



Advertisements
Advertisements