Write a Java program to create a unique identifier of a given string.

Java Programming Language String in java (Article) String in java (Program)

1140

Program:

public class Exercise {

  public static void main(String[] args)
    {
        String str = "Python Exercises.";

        // Get the hash code for the above string.
        int hash_code = str.hashCode();

        // Display the hash code.
        System.out.println("The hash for " + str +
            " is " + hash_code);
    }
}

Output:

The hash for Python Exercises. is 863132599
Press any key to continue . . .

Explanation:

None

This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.