Java Reflection - Java Constructor.getModifiers()


Constructor.getModifiers() has the following syntax.

public int getModifiers()


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

import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
/*w ww  . j a va  2 s. co m*/
public class Main {
  public static void main(String... args) throws Exception {
    Class<?> c = Class.forName("java.lang.String");
    Constructor[] allConstructors = c.getDeclaredConstructors();
    for (Constructor ctor : allConstructors) {

The code above generates the following result.