Here you can find the source of getGetter(Class c, Field field)
public static Method getGetter(Class c, Field field)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Field; import java.lang.reflect.Method; public class Main { public static Method getGetter(Class c, Field field) { String fieldName = field.getName(); //if boolean String methodName = "get" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); try {/*from www.j av a2 s.c om*/ Method result = c.getMethod(methodName); return result; } catch (SecurityException e) { e.printStackTrace(); //? return null; } catch (NoSuchMethodException e) { methodName = "is" + methodName.substring(3); try { Method result = c.getMethod(methodName); return result; } catch (SecurityException ex) { e.printStackTrace(); //? return null; } catch (NoSuchMethodException ex) { return null; } } } }