The Modifier class provides static methods and constants to decode class and member access modifiers.
Return | Field | Summary |
---|---|---|
static int | ABSTRACT | The int value representing the abstract modifier. |
static int | FINAL | The int value representing the final modifier. |
static int | INTERFACE | The int value representing the interface modifier. |
static int | NATIVE | The int value representing the native modifier. |
static int | PRIVATE | The int value representing the private modifier. |
static int | PROTECTED | The int value representing the protected modifier. |
static int | PUBLIC | The int value representing the public modifier. |
static int | STATIC | The int value representing the static modifier. |
static int | STRICT | The int value representing the strictfp modifier. |
static int | SYNCHRONIZED | The int value representing the synchronized modifier. |
static int | TRANSIENT | The int value representing the transient modifier. |
static int | VOLATILE | The int value representing the volatile modifier. |
Return | Method | Summary |
---|---|---|
static boolean | isAbstract(int mod) | Is abstract modifier. |
static boolean | isFinal(int mod) | Is final modifier. |
static boolean | isInterface(int mod) | Is interface modifier. |
static boolean | isNative(int mod) | Is native modifier. |
static boolean | isPrivate(int mod) | Is private modifier. |
static boolean | isProtected(int mod) | Is protected modifier. |
static boolean | isPublic(int mod) | Is public modifier. |
static boolean | isStatic(int mod) | Is static modifier. |
static boolean | isStrict(int mod) | Is strictfp modifier. |
static boolean | isSynchronized(int mod) | Is synchronized modifier. |
static boolean | isTransient(int mod) | Is transient modifier. |
static boolean | isVolatile(int mod) | Is volatile modifier. |
static String | toString(int mod) | Convert modifier int flag to string. |
Return true if the integer argument includes the public modifier, false otherwise
import java.lang.reflect.Modifier;
public class Main {
public static void main(String[] args) throws Exception {
getClassModifier(String.class);
}
private static void getClassModifier(Class clazz) {
int modifier = clazz.getModifiers();
if (Modifier.isPublic(modifier)) {
System.out.println(clazz.getName() + " class modifier is public");
}
}
}
The output:
java.lang.String class modifier is public
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. |