The getModifiers () method of java.lang.reflect.Field used to return the modifiers used for the field object as time of declaration, as an integer. The Modifier class should be used to decode the modifiers. Syntax:
public int getModifiers()
Parameters: This method accepts nothing. Return: This method returns the Java language modifiers for the underlying member. Below programs illustrate getModifiers () method: Program 1:Â
Java
// Java program to illustrate // getModifiers () method Â
import java.lang.reflect.Field; import java.lang.reflect.Modifier; Â
public class GFG { Â
    // initialize field     private static int number; Â
    public static void main(String[] args)         throws NoSuchFieldException     {         // get Field object         Field field             = GFG. class                   .getDeclaredField("number"); Â
        // apply getModifiers() method         int modifiers             = field.getModifiers(); Â
        // print the results         System.out.println(             Modifier                 .toString(modifiers));     } } |
private static
Program 2:Â
Java
// Java program to illustrate // getModifiers () method Â
import java.lang.reflect.Field; import java.lang.reflect.Modifier; Â
public class GFG { Â
    // initialize field     final static String value         = "Geeks"; Â
    public static void main(String[] args)         throws NoSuchFieldException     { Â
        // get Field object         Field field             = GFG. class                   .getDeclaredField("value"); Â
        // apply getModifiers() method         int modifiers             = field.getModifiers(); Â
        // print the results         System.out.println(             Modifier                 .toString(modifiers));     } } |
static final
References: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Field.html#getModifiers–