Java.lang.StackTraceElement.hashCode() Method


Advertisements


Description

The java.lang.StackTraceElement.hashCode() method returns a hash code value for this stack trace element.

Declaration

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

public 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.StackTraceElement.hashCode() method.

package com.tutorialspoint;

import java.lang.*;

public class StackTraceElementDemo {

   public static void main(String[] args) {

   function1();
   }
 
   public static void function1()
   {
   new StackTraceElementDemo().function2();
   }
 
   public void function2() 
   {
   int i;
   System.out.println("hash code : ");
    
   // print stack trace
   for(i = 1 ; i < 3 ; i++) {
   System.out.println(Thread.currentThread().getStackTrace()[i].
   hashCode());
   }
   }
}   

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

hash code :
2115854044
2115853075

java_lang_stacktraceelement.htm

Advertisements