Online Java Compiler By
JavaTpoint.com
//import statement import java.lang.reflect.Method; public class ReflectMethodgetNameExample1 { public static void main(String[] args) { Method[] mthd = TestX1.class.getMethods(); for (Method mthd1 : mthd) { System.out.println("Method: " + mthd1.getName()); } } } class TestX1 { private String TestField; public String getSampleField() { return TestField; } public void setSampleField(String TestField) { this.TestField = TestField; } }
Output