Java Modifier STATIC

Syntax

Modifier.STATIC has the following syntax.

public static final int STATIC

Example

In the following code shows how to use Modifier.STATIC field.


import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
/*from   ww  w .  ja  va2  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) {
      int searchMod = Modifier.STATIC;
      int mods = accessModifiers(ctor.getModifiers());
      if (searchMod == mods) {
        System.out.println(ctor);
      }
    }
  }

  private static int accessModifiers(int m) {
    return m & Modifier.STATIC;
  }
}




















Home »
  Java Tutorial »
    java.lang.reflect »




Array
Constructor
Field
Method
Modifier
ParameterizedType
TypeVariable