Java tutorial
//package com.java2s; public class Main { public static void setObjValue(String methodName, Object object, String value) { try { Class<? extends Object> cls = object.getClass(); cls.getMethod(methodName, String.class).invoke(object, value); } catch (Exception e) { e.printStackTrace(); } } }