Function pointer
Hi ,What is function pointer?How do i pass function pointer to a method?Thanks in Advance
[117 byte] By [
pranathia] at [2007-11-26 19:01:03]

> Hi ,> > What is function pointer?A pointer to a function> > How do i pass function pointer to a method?> You dont, pointers are not available in Java.> Thanks in AdvanceOkily dokily
In java you can at least emulate a function pointer through a class that invokes Runnable. This won't allow you to pass a method around, but you can implement your logic in the run() method of the Runnable and then pass that Runnable around.
The Java Programming Language doesn't provide function pointers in the usual sense.
In other languages (e. g. in C++) a function pointer is the address of a function. You can, for example, specify function pointers as parameters of functions.
In Java, you can use interfaces instead of function pointers. Declare a interface with (usually) a single method a provide different implementations. Then, instances of these implementations can be handled similarly as function pointers.