Here you can find the source of getMethod(Object object, String name, Object... params)
Parameter | Description |
---|---|
object | container of method |
name | name of method |
params | params of method |
public static Method getMethod(Object object, String name, Object... params)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; public class Main { /***/*from ww w. j av a2s.c o m*/ * get method by name * * @param object container of method * @param name name of method * @param params params of method * @return requested method */ public static Method getMethod(Object object, String name, Object... params) { try { List<Class> classParams = new ArrayList<>(); for (int i = 0; i < params.length; i++) { classParams.add((Class) params[i]); } Class<?> classParamsArray[] = new Class[classParams.size()]; classParams.toArray(classParamsArray); return object.getClass().getMethod(name, classParamsArray); } catch (NoSuchMethodException e) { } return null; } }