0

I am not sure if this is possible but here is what I wanted to achieve using java.
I want to write a function in JAVA (say genericFunc) with another function's signature or name (lets say randomFunc) and its parameters (randomFuncParam) as parameters to genericFunc. Now the genericFunc(randomFunc, randomFuncParam) should execute randomFunc by passing in the parameters. This is something like:

void randomFunc1(int randomFuncParam){
    syso(randomFuncParam-1);
}

void randomFunc2(String randomFuncParam){
    syso(randomFuncParam+"----"+randomFuncParam);
}

void genericFunc(<func and funcParam>){
//call func here with funcParam
}

So calling:

genericFunc(<randomFunc1 and 10>) should print 9

and

genericFunc(<randomFunc2 and Hello>) should print Hello----Hello
Destructor
  • 3,154
  • 7
  • 32
  • 51

0 Answers0