Introduction

The java.lang.reflect.Modifier class provides static methods and constants to decode class and member access modifiers. The sets of modifiers are represented as integers with distinct bit positions representing different modifiers. The values for the constants representing the modifiers are taken from the tables in sections 4.1, 4.4, 4.5, and 4.7 of The Java Virtual Machine Specification.

Class declaration

Following is the declaration for java.lang.reflect.Modifier class −

public class Modifier
   extends Object

Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career.

Fields

Following are the fields for java.lang.reflect.Modifier class −

  • 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.

Constructors

Sr.No.Constructor & Description
1Modifier()Default Constructor.

Class methods

Sr.No.Method & Description
1static int classModifiers()Return an int value OR-ing together the source language modifiers that can be applied to a class.
2static int constructorModifiers()Return an int value OR-ing together the source language modifiers that can be applied to a constructor.
3static int fieldModifiers()Return an int value OR-ing together the source language modifiers that can be applied to a field.
4static int interfaceModifiers()Return an int value OR-ing together the source language modifiers that can be applied to an interface.
5static boolean isAbstract(int mod)Return true if the integer argument includes the abstract modifier, false otherwise.
6static boolean isFinal(int mod)Return true if the integer argument includes the final modifier, false otherwise.
7static boolean isInterface(int mod)Return true if the integer argument includes the interface modifier, false otherwise.
8static boolean isNative(int mod)Return true if the integer argument includes the native modifier, false otherwise.
9static boolean isPrivate(int mod)Return true if the integer argument includes the private modifier, false otherwise.
10static boolean isProtected(int mod)Return true if the integer argument includes the protected modifier, false otherwise.
11static boolean isPublic(int mod)Return true if the integer argument includes the public modifier, false otherwise.
12static boolean isStatic(int mod)Return true if the integer argument includes the static modifier, false otherwise.
13static boolean isStrict(int mod)Return true if the integer argument includes the strictfp modifier, false otherwise.
14static boolean isSynchronized(int mod)Return true if the integer argument includes the synchronized modifier, false otherwise.
15static boolean isTransient(int mod)Return true if the integer argument includes the transient modifier, false otherwise.
16static boolean isVolatile(int mod)Return true if the integer argument includes the volatile modifier, false otherwise.
17static int methodModifiers()Return an int value OR-ing together the source language modifiers that can be applied to a method.
18static String toString(int mod)Return a string describing the access modifier flags in the specified modifier.

Methods inherited

This class inherits methods from the following classes −

  • java.lang.Object

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *