Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.lang.reflect.Method;

public class Main {
    public static Object getObjValue(String methodName, Object object) {
        try {
            Class<? extends Object> cls = object.getClass();
            Method fieldMethod = cls.getMethod(methodName);
            if (fieldMethod != null) {
                return fieldMethod.invoke(object);
            }
            return null;
        } catch (Exception e) {
        }
        return null;
    }
}