In C++ when I have algorithm which could accept different behaviour in runtime I rather use function pointer.
For example, a program for drawing charts has one algorithm to draw line which can accept any function to specialize shape of this line.
In Java there are no function pointers and I am obliged to use either the strategy pattern or reflection (or another pattern).
How to to enable special behavior to be selected at runtime in my programme? Strategy pattern either function pointer?
In Java function pointers are implemented using functors. Create an interface with one function and pass instances of it instead of function pointers. Let's your code in C++ looked like:
void func(void (*f)(int par));
In Java this would look like:
public interface F {
public void f(int par);
}
void func(F f);
Take a look at Guava's Function class. This is also not a bad approach for C++ as well. It is more readable and allows user to pass in objects with state as opposed to static functions.