Hm. How about an example. You write a quick sort algorithm in C. A user who wants to use your algorithm must provide a comparison method suitable for the user to sort with your algorithm. The user must pass a pointer to a method for comparing users with your quick sort code. Quicksort code uses this address, a function pointer, to call the CALL BACK function for the user. You provide a function prototype, no implementation, because you cannot know how to determine the routine of what is sorted. The user supplies a comparison implementation that makes sense for the user to sort. This implementation must match the function prototype. The function pointer is used by the quicksort agorism to go back and touch the user code.
It is actually about polymorphism.
In java you can use an interface for this. Therefore, for sorting, see IComparer and IComparable Interface.
JAL Feb 19 '11 at 2:44 2011-02-19 02:44
source share