Java Reflection - Java Constructor.hashCode()








Syntax

Constructor.hashCode() has the following syntax.

public int hashCode()

Example

In the following code shows how to use Constructor.hashCode() method.

import java.lang.reflect.Constructor;
import java.util.ArrayList;
//ww  w  . j a  va 2 s . c o m
public class Main {
  public static void main(String[] argv) throws Exception {
      Constructor[] constructors = ArrayList.class.getDeclaredConstructors();

      for (int i = 0; i < constructors.length; i++) {
        Constructor c = constructors[i];
        System.out.println(c.hashCode());
      }
    }
  
}

The code above generates the following result.