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

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 line of code. This is a perfect application for passing in a function pointer to replace that one line, but Java doesn’t have function pointers. What’s my best alternative?

22 Answers
22

Leave a Comment