What's the nearest substitute for a function pointer in Java?

前端 未结 22 1771
太阳男子
太阳男子 2020-11-22 15:32

I have a method that\'s about ten lines of code. I want to create more methods that do exactly the same thing, except for a small calculation that\'s going to change one li

22条回答
  •  情深已故
    2020-11-22 16:14

    Check out lambdaj

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

    and in particular its new closure feature

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

    and you will find a very readable way to define closure or function pointer without creating meaningless interface or use ugly inner classes

提交回复
热议问题