Is it possible in J2ME to call/invoke a method by its name.just like we have开发者_Go百科 getDeclaredMethod in java .
The java.lang.reflect
package is available only in CDC 1.1.2. If you're not on such configuration, you're out of luck. There is no way to invoke a method by name without reflection.
A workaround would be to create a map from strings (method names) to appropriate classes on which you can invoke the methods.
Closest you can get is to instantiate a class by name using Class.forName("com.class.ClassName").newInstance()
-- that will execute a parameterless constructor.
精彩评论