Dealing with two Classes : Using method from one Class as a parameter to another
Is using a method from one class as a parameter for another class possible?
Now making a method for my Class2(Different class file from Class1), is it possible to take ONLY initialA's results of "money++" as one of my parameter, and not take the results of a++ or b++ (assuming these are all int) ?
public void initialA ()
if(money == 2)
Re: Dealing with two Classes : Using method from one Class as a parameter to another
I'm not sure what your question is.
You can not pass a method as a parameter to another method. You can pass a reference to an instance of a class that has the desired method as a parameter in method call.
When you call a method like initialA(), it will execute its statements in the order they are coded. The caller can not specify which statements are to be executed. The initialA() method would have to be specially coded and take a parameter that would tell it what to do.