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 getValueByMethodName(Object o, String methodName) {
        try {
            Method method = o.getClass().getMethod(methodName, new Class[] {});
            Object value = method.invoke(o, new Object[] {});
            return value;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}