Java JDOM Document hashCode() Method



The Java JDOM hashCode() method of Document class is used to get the hash code of an XML document. Hash code is a unique integer value that is used to a identify XML documents individually. This hash code is used to check data integrity and other security concerns of XML documents.

Syntax

Following is the syntax of the Java JDOM Document hashCode() method −

Document.hashCode();

Parameters

The Java hashCode() method doesn't accept any parameters.

Return Value

The Java hashCode() method returns the hash code as integer value.

Example

Here is the basic example of using the Java JDOM Document hashCode() method −

import org.jdom2.Document;

public class GetHashCode {
   public static void main(String args[]) {
      try {
    	 //Creating new document
    	 Document doc = new Document();
    	 int hashCode = doc.hashCode();
    	 System.out.println("Hash code of this document: "+hashCode);
      } catch(Exception e) {
    	 e.printStackTrace();
      } 
   }
}

The Hash code of the XML document is displayed.

Hash code of this document: 1599771323
Advertisements