带有类类型的JavareflectiongetDeclaredMethod()

我正在尝试理解Javareflection,并且在使用非整数setter方法时遇到了困难。

举个例子,我如何解决下面的“getDeclaredMethod()”调用?

import java.lang.reflect.*; class Target { String value; public Target() { this.value = new String("."); } public void setValue(String value) { this.value = value; } public String getValue() { return this.value; } } class ReflectionTest { public static void main(String args[]) { try { Class myTarget = Class.forName("Target"); Method myMethod; myMethod = myTarget.getDeclaredMethod("getValue"); // Works! System.out.println("Method Name: " + myMethod.toString()); Class params[] = new Class[1]; //params[0] = String.TYPE; // ?? What is the appropriate Class TYPE? myMethod = myTarget.getDeclaredMethod("setValue", params); // ? Help ? System.out.println("Method Name: " + myMethod.toString()); } catch (Exception e) { System.out.println("ERROR"); } } } 

 params[0] = String.class; 

String上使用class将返回与String类关联的Class