Here you can find the source of invoke(Object o, String name)
Parameter | Description |
---|---|
o | not null |
name | not null |
public static Object invoke(Object o, String name)
//package com.java2s; /*//from w w w .ja v a 2 s .c o m * Copyright (c) TESOBE Ltd. 2017. All rights reserved. * * Use of this source code is governed by a GNU AFFERO license that can be found in the LICENSE file. * */ import java.lang.reflect.Method; public class Main { /** * Invoke zero parameter method name. * * @param o not null * @param name not null * * @return o.name() */ public static Object invoke(Object o, String name) { try { Method method = o.getClass().getMethod(name); method.setAccessible(true); return method.invoke(o); } catch (Exception e) { return null; } } }