Mark Mark - 4 years ago 581
Java Question

Java Delegates?

Does the Java language have delegate features, similar to how C# has support for delegates?

Answer Source

Not really, no.

You may be able to achieve the same effect by using reflection to get Method objects you can then invoke, and the other way is to create an interface with a single 'invoke' or 'execute' method, and then instantiate them to call the method your interested in (i.e. using an anonymous inner class).

You might also find this article interesting / useful : A Java Programmer Looks at C# Delegates

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download