Showing posts with label function-pointers. Show all posts
Showing posts with label function-pointers. Show all posts

Wednesday, May 30, 2012

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


I have a method that's about 10 lines of code. I want to create more methods that do the exact same thing except for a 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?