<分区>
Possible Duplicate:
How do I invoke a java method when given the method name as a string?
How do I programmatically compile and instantiate a Java class?
我有一个函数:
fun1() {
System.out.print("hello");
}
我想从用户或文件中读取一个字符串,如果出现字符串 "fun1()"
,我会调用 fun1。
我不想用 switch 语句来做这个,因为我有很多函数。
有什么方法可以使用字符串调用函数吗?