Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Modifiers fieldModifiers() method in Java with Examples

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The fieldModifiers() method of java.lang.reflect.Modifier class is used to get an integer value together with the modifiers of source language that can be applied to a field.

Syntax:

public static boolean fieldModifiers()

Parameters: This method accepts nothing.

Return: This method returns an int value OR-ing together the source language modifiers that can be applied to a field.
.

Below programs illustrate fieldModifiers() method:
Program 1:




// Java program to illustrate
// fieldModifiers() method
  
import java.lang.reflect.*;
  
public class GFG {
  
    public static void main(String[] args)
        throws NoSuchFieldException,
               SecurityException
    {
  
        // get Modifier using fieldModifiers()
        int result = Modifier.fieldModifiers();
  
        System.out.println(
            "Field Modifiers: "
            + Modifier.toString(result));
    }
}

Output:

Field Modifiers: public protected private static final transient volatile

Program 2:




// Java program to illustrate fieldModifiers()
  
import java.lang.reflect.*;
  
public class GFG {
  
    public static void main(String[] args)
        throws NoSuchFieldException,
               SecurityException
    {
  
        // get Modifier using fieldModifiers()
        int result = Modifier.fieldModifiers();
  
        System.out.println(
            "Int Value: "
            + result);
    }
}

Output:

Int Value: 223

References: https://docs.oracle.com/javase/10/docs/api/java/lang/reflect/Modifier.html#fieldModifiers()


My Personal Notes arrow_drop_up
Last Updated : 24 Sep, 2019
Like Article
Save Article
Similar Reads
Related Tutorials