Online Java Compiler By
JavaTpoint.com
//import statements import java.lang.reflect.Method; public class ClassgetDeclaredMethodsExample2 { public static void main(String... args) throws NoSuchMethodException { Class
obj = Sample1.class; Method mthd[] = obj.getDeclaredMethods(); for(int i = 0; i < mthd.length; i++) { System.out.println("Method (" +(i+1)+ ")" +mthd[i].toString()); //get the methods and convert into string } } private static class Sample1 { private void Method1() { } public void Methodint(int i) { } } }
Output