---
title: "java反射调用有参方法"
author: "shaq34"
date: "2009-08-01T11:14:26Z"
tags: []
slug: "java"
draft: false
lastmod: "2009-08-21T10:20:58Z"
id: 437472
url: "https://shaq34.iteye.com/blog/437472"
---

```java

Object obj = Class.forName("").newInstance();

public void invokeMethod(Object obj, String methodName, Object[] param)
			throws Exception {
		Class clazz = obj.getClass();
		Class[] classArgs = new Class[param.length];
		for (int i = 0; i < param.length; i++) {
			classArgs[i] = param[i].getClass();
		}
		Method method = clazz.getMethod(methodName, classArgs);
		method.invoke(obj, param);
	}


```