Here you can find the source of getSetter(Class> clazz, Field field)
public static Method getSetter(Class<?> clazz, Field field)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Field; import java.lang.reflect.Method; public class Main { public static Method getSetter(Class<?> clazz, Field field) { Class<?> fieldType = field.getType(); String filedName = field.getName(); String firstLetter = filedName.substring(0, 1).toUpperCase(); String setMethodName = "set" + firstLetter + filedName.substring(1); Method setMethod = null;//from www . j a v a2 s .c om try { setMethod = clazz.getDeclaredMethod(setMethodName, fieldType); } catch (Exception e) { } return setMethod; } }