Here you can find the source of getMethod(Object obj, String fieldName)
Parameter | Description |
---|---|
obj | the object to look at. |
fieldName | the name of the field in the object. |
Parameter | Description |
---|---|
BuildException | if there is an error. |
public static Method getMethod(Object obj, String fieldName)
//package com.java2s; import java.lang.reflect.Method; public class Main { /**/*from w w w .j av a2 s . c om*/ * Get a field in an object. * * @param obj the object to look at. * @param fieldName the name of the field in the object. * @return the value of the field. * @throws BuildException if there is an error. */ public static Method getMethod(Object obj, String fieldName) { try { Method method = obj.getClass().getMethod("get" + fieldName); return method; } catch (Exception t) { return null; // NotReached } } }