Modifiers methodModifiers() method in Java with Examples

The methodModifiers() 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 Method.

Syntax:

public static boolean methodModifiers()

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

Below programs illustrate methodModifiers() method:
Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

Method Modifiers:
 public protected private abstract
 static final synchronized native strictfp

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

Int Value: 3391

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



My Personal Notes arrow_drop_up

I am a Developer I love to code and bring my ideas alive

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.