Java equivalent of PHP's variable-variables?
Hi to those of you familiar with PHP,
Here's some example code in PHP:
public function foo($a, $b)
//Do something with $a and $b.
public function bar($x, $y)
//Do something completely different with $x, $y.
public function fred($q, $r)
//Do something else
public function ... //etc (lots of functions).
$mc = new MyClass;
if (method_exists($mc, $method))
So, I'd like to be able to do this in Java without a huge if block that tediously goes through: if method == "foo" then call foo, else if method == "bar" then call bar, etc, etc ... *yawn*!
Can someone tell me how to do this please?
Many thanks in advance.