Get Modifiers

ReturnMethodSummary
intgetModifiers()Returns the Java language modifiers for this class or interface, encoded in an integer.

import java.lang.reflect.Modifier;

public class Main {

  public static void main(String[] args) {
   Class c = new String().getClass();
    int m = c.getModifiers();
    if (Modifier.isPublic(m))
      System.out.println("public");
    if (Modifier.isAbstract(m))
      System.out.println("abstract");
    if (Modifier.isFinal(m))
      System.out.println("final");
  }
}

The output:


public
final
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.