Online Java Compiler By
JavaTpoint.com
//import statement import java.lang.reflect.Method; import java.lang.reflect.Modifier; public class ReflectMethodgetModifierExample1 { public static void main(String[] args) { try { Class obj1 = MyDemo.class; Method[] mthd = obj1.getMethods(); Method setValueMethodObject = mthd[0]; int mdfr = setValueMethodObject.getModifiers(); //get the modifier System.out.println("Modifier of setValueDemo():"); System.out.println(Modifier.toString(mdfr)); } catch (Exception e) { e.printStackTrace(); } } class MyDemo { public int setValueDemo() { System.out.println("setValueDemo"); return 22; } } }
Output