2

Is it possible in J2ME to call/invoke a method by its name.just like we have getDeclaredMethod in java .

2 Answers 2

2

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.

0
0

Closest you can get is to instantiate a class by name using Class.forName("com.class.ClassName").newInstance() -- that will execute a parameterless constructor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.