Java Constructor.getModifiers()

Syntax

Constructor.getModifiers() has the following syntax.

public int getModifiers()

Example

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


import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
//from  w w w. j  av a2s .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) {
      System.out.println(Modifier.toString(ctor.getModifiers()));
    }
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang.reflect »




Array
Constructor
Field
Method
Modifier
ParameterizedType
TypeVariable