Does the Java language have delegate features, similar to how C# has support for delegates?
+11
A:
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
Matt Sheppard
2008-09-04 22:54:49
+1
A:
While it is nowhere nearly as clean, but you could implement something like C# delegates using a Java Proxy.
John Meagher
2008-09-05 00:07:23
+1
A:
I have implemented callback/delegate support in Java using reflection. Details and working source are available on my website.
Software Monkey
2010-01-16 00:17:11