• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

substitute string in methods name?

 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Maneesh Godbole
Saloon Keeper
Posts: 11175
14
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15481
43
Android IntelliJ IDE Java Scala Spring
 
Campbell Ritchie
Sheriff
Pie
Posts: 50180
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nimo frey wrote: . . .
You would mean "a.get" + what; surely? Maneesh and Jesper have already answered.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic