Passing methods as arguments | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Passing methods as arguments

I know that in some languages, you can pass functions or methods as arguments of another, so that it could be called later by the latter method. (Example: Passing method A into method B, so that method A will be called inside method B) (Example: Passing method C into method B, so that method C, not method A, will be called inside method B) Is this possible in Java? If so, how?

10th Mar 2020, 3:25 PM
Kino -Imsure1200q
Kino -Imsure1200q - avatar
2 Answers
+ 2
I don't speak Java, but I found this, which seems to show several ways to do it: https://stackoverflow.com/questions/2186931/java-pass-method-as-parameter
10th Mar 2020, 3:29 PM
HonFu
HonFu - avatar
0
https://code.sololearn.com/cybCh5BLNgeF/#
11th Mar 2020, 2:49 AM
zemiak