VOOZH about

URL: https://www.geeksforgeeks.org/java/java-lang-reflect-modifier-class-in-java/

⇱ java.lang.reflect.Modifier Class in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

java.lang.reflect.Modifier Class in Java

Last Updated : 9 Mar, 2021

The java.lang.reflect.Modifier class contains methods used to get information about class, member and method access modifiers. The modifiers are represented as int value with set bits at distinct positions. The int value represents different modifiers. These values are taken from the tables in sections 4.1, 4.4, 4.5, and 4.7 of The JVM Specification.

Class declaration:

Public class modifier extends Object

Fields:

FieldDescription
ABSTRACT Integer value representing the abstract modifier.
FINAL Integer value representing the final modifier.
INTERFACE Integer value representing the interface modifier.
NATIVE Integer value representing the native modifier.
PRIVATE Integer value representing the private modifier.
PROTECTED Integer value representing the protected modifier.
PUBLIC Integer value representing the public modifier.
STATIC Integer value representing the static modifier.
STRICT Integer value representing the strictfp modifier.
SYNCHRONIZED Integer value representing the synchronized modifier.
TRANSIENT Integer value representing the transient modifier.
VOLATILE Integer value representing the volatile modifier.

Constructor:

public Modifier(): Default constructor

Methods:

MethodDescription
classModifiers()This method returns an int value OR-ing together the source language modifiers that can be applied to a class.
constructorModifiers() This method returns an int value OR-ing together the source language modifiers that can be applied to a constructor.
fieldModifiers() This method returns an int value OR-ing together the source language modifiers that can be applied to a field.
interfaceModifiers() This method returns an int value OR-ing together the source language modifiers that can be applied to an interface.
isAbstract(int mod)This method returns true if the integer argument includes the abstract modifier, false otherwise.
isFinal(int mod) This method returns true if the integer argument includes the final modifier, false otherwise.
isInterface(int mod) This method returns true if the integer argument includes the interface modifier, false otherwise.
isNative(int mod) This method returns true if the integer argument includes the native modifier, false otherwise.
isPrivate(int mod) This method returns true if the integer argument includes the private modifier, false otherwise.
isProtected(int mod) This method returns true if the integer argument includes the protected modifier, false otherwise.
isPublic(int mod) This method returns true if the integer argument includes the public modifier, false otherwise.
isStatic(int mod) This method returns true if the integer argument includes the staticfp modifier, false otherwise.
isSynchronized(int mod) This method returns true if the integer argument includes the synchronized modifier, false otherwise.
isTransient(int mod) This method returns true if the integer argument includes the transient modifier, false otherwise.
isVolatile(int mod) This method returns true if the integer argument includes the volatile modifier, false otherwise.
methodModifiers() This method returns an int value OR-ing together the source language modifiers that can be applied to a method.
parameterModifiers() This method returns an int value OR-ing together the source language modifiers that can be applied to a parameter.
toString(int mod) This method returns a string describing the access modifier flags in the specified modifier.

1. static int classModifiers(): 

This method returns an int value after performing OR operation on the access modifiers that can be applied to a class.

Return type: Integer

Output
3103
public protected private abstract static final strictfp

2. static int constructorModifiers(); Returns an int value after performing OR operation on the access modifiers that can be applied to a constructor.

Return type: Integer

Output
7
public protected private

3. static int fieldModifiers(): Returns an int value after performing OR operation on the access modifiers that can be applied to a field.

Return type: Integer

Output
223
public protected private static final transient volatile

4. static int interfaceModifiers(): Returns an int value after performing OR operation on the access modifiers that can be applied to an interface.

Return type: Integer

Output
3087
public protected private abstract static strictfp

6. static boolean isAbstract(): Checks whether the integer argument includes the abstract modifier.

Return type: boolean

Output
true

7. static boolean isFinal(): Checks whether the integer argument includes the abstract modifier.

Return type: boolean

Output
true

8. static boolean isInterface(): Checks whether the integer argument includes the abstract modifier.

Return type: boolean

Output
true

9. static boolean isNative(): Checks whether the integer argument includes the abstract modifier.

Return type: boolean

Output
true

10. static boolean isPrivate(): Checks whether the integer argument includes the abstract modifier.

Return type: boolean

Output
true

11. static boolean isProtected(): Checks whether the integer argument includes the abstract modifier.

Return type: boolean

Output
true

12. static boolean isPublic(): Checks whether the integer argument includes the abstract modifier.

Return type: boolean

Output
true

13. static boolean isStatic(): Checks whether the integer argument includes the abstract modifier.

Return type: boolean

Output
true

14. static boolean isStrict(): Checks whether the integer argument includes the abstract modifier.

Return type: boolean

Output
false

15. static boolean isSynchronized(): Checks whether the integer argument includes the abstract modifier.

Return type: boolean

Output
true

16. static boolean isTransient(): Checks whether the integer argument includes the abstract modifier.

Return type: boolean

Output
true

17. static boolean isVolatile(): Checks whether the integer argument includes the abstract modifier.

Return type: boolean

Output
true

18. static int methodModifiers(): Returns an int value after performing OR operation on the values of access modifiers that can be applied to a method.

Return type: Integer

Output
3391
Comment