Alex Rivera | Logout

Callback functions in Java

Asked 2009-01-14T16:40:16.227
214

Is there a way to pass a call back function in a Java method?

The behavior I'm trying to mimic is a .Net Delegate being passed to a function.

I've seen people suggesting creating a separate object but that seems overkill, however I am aware that sometimes overkill is the only way to do things.

Edit
Report

1 Answer

4

Check the closures how they have been implemented in the lambdaj library. They actually have a behavior very similar to C# delegates:

http://code.google.com/p/lambdaj/wiki/Closures

answered 2009-09-12T13:32:51.957

Your Answer