Here's the setup of my program. I want to tell the method checkerMethod which method to use, from either method1 or method2.
public Class executeCode{
World brave = new World();
brave.checkerMethod(Method method1);
}
My world class looks something like below.
public World{ // changed to World from World()
public World(){
//make world
}
public methodChecker(Method method){
//code involving using method1 or method2
//methods 1 and 2 are not static, so I would need to call this.method1()
}
public void method1(){//method here}
public void method2(){//method here}
}
I have seen similar things, here, for instance
The solution above would not work obviously for passing non-static methods.
I have a feeling that if I rearrange things it may work, but I can't figure it out. Any help would be appreciated!