ClasspersonClass = Person.class; Method[] methods = personClass.getMethods(); for (Method method : methods) { if (method.getName().equals("printName")) { System.out.println("Method name: " + method.getName()); } }
import org.apache.poi.hssf.usermodel.HSSFCellStyle; import java.lang.reflect.Method; ClassIn this example, we import the HSSFCellStyle class from the org.apache.poi.hssf.usermodel package and use getMethods() to retrieve all of the methods declared in this class. The package library for these examples is not specified, but they both use the java.lang.reflect.Method class, which is in the java.lang.reflect package.styleClass = HSSFCellStyle.class; Method[] methods = styleClass.getMethods(); for (Method method : methods) { System.out.println("Method name: " + method.getName()); }