Online Java Compiler By
JavaTpoint.com
//import statements import java.lang.reflect.Method; public class ClassgetNameExample2 { public static void main(String[] args) { try { Class obj = ClassgetNameExample2.class; Method[] mthd = obj.getMethods(); for (Method method : mthd) { String MthdNm = method.getName(); System.out.println("Name of the method: " + MthdNm); } } catch (Exception e) { e.printStackTrace(); //print exception object } } public static int setValueMethod() { System.out.println("setValueMethod"); return 22; } public String getValueMethod() { System.out.println("getValueMethod"); return "getValueMethod"; } public void setManyValuesMethod() { System.out.println("setManyValuesMethod"); } }
Output