How to call Java function from string stored in a Variable

Posted by Lizard on Stack Overflow See other posts from Stack Overflow or by Lizard
Published on 2010-06-14T15:25:31Z Indexed on 2010/06/14 15:32 UTC
Read the original article Hit count: 241

Filed under:
|
|

I need to be able to call a function, but the function name is stored in a variable, is this possible. e.g:

public void foo ()
{
  //code here
}

public void bar ()
{
  //code here
}

String functionName = "foo";

// i need to call the function based on what is functionName

Anyhelp would be great, thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about reflection