Online Java Compiler By
JavaTpoint.com
//import statements import java.lang.reflect.*; public class ClassgetDeclaredMethodsExample1 { public static void main(String[] args) { ClassgetDeclaredMethodsExample1 obj = new ClassgetDeclaredMethodsExample1(); Class class1 = obj.getClass(); try { // parameter type is null Method mthd[] = class1.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 } } catch(Exception e) { System.out.println(e.toString()); //print the exceptio object e } } private Integer showmethod() { return 1; } public void showIntegermethod(Integer i) { this.i = i; } public void showFloatmethod(float i) { this.f = f; } public int i = 88655; float f=3; }
Output