Java tutorial
//package com.java2s; import java.lang.reflect.Method; import java.lang.reflect.Modifier; public class Main { private static Method findGetter(Method[] methods, String name, Class<?> paramType) { String getterName = "get" + name; String isGetterName = "is" + name; for (Method method : methods) { if (Modifier.isStatic(method.getModifiers())) { continue; } String methodName = method.getName(); if (!methodName.equals(getterName) && !methodName.equals(isGetterName)) { continue; } if (!method.getReturnType().equals(paramType)) { continue; } if (method.getParameterTypes().length == 0) { return method; } } return null; } }