Forums Register Login
substitute string in methods name?
I have something like:

you see, the getX is a Method-Name.

Now, I have something like this:

Unfortunately, this does not work. Is there another way to achieve this?
What are you trying to achieve exactly? Looks like you want to figure out at runtime which method should be invoked. Is that correct?

One way to do it is to get a list of all methods using reflection, iterate through them, get the names, compare the method name with your string and invoke it if required.
Reflection is the way to do this.

nimo frey wrote: . . .

You would mean "a.get" + what; surely? Maneesh and Jesper have already answered.
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
Why should you try IntelliJ IDEA ?

This thread has been viewed 833 times.

All times above are in ranch (not your local) time.
The current ranch time is
Aug 18, 2018 14:44:25.