N
N
Noortvel2015-10-19 10:27:24
Java
Noortvel, 2015-10-19 10:27:24

Java.Is it possible to pass a method as an argument?

How to pass a method as an argument? That is,
public void activity (// method here) {
// The rest of the code
// Method execution here
}
PS java 7

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
programmerjava, 2015-10-19
@Noortvel

Pass the interface with the desired method. Most often it is an interface with one method.
For example, Thread uses Runnable. It has one run() method. If you need a method with arguments, then create a similar interface.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question