Function Pointers

B

ballpointpenthief

Hello,
I was wondering what is Java's answer to function pointers?

Thanks,
Matt
 
J

Jeffrey Schwab

ballpointpenthief said:
I was wondering what is Java's answer to function pointers?

Interfaces. The rough equivalent of "void (*)();", for example, is
Runnable. There is also a Method object in the standard API.
 
P

Patricia Shanahan

ballpointpenthief said:
Hello,
I was wondering what is Java's answer to function pointers?

Classes implementing interfaces, such as Runnable, and the various
*Listener interfaces.

Patricia
 
J

Jussi Piitulainen

ballpointpenthief said:
I was wondering what is Java's answer to function pointers?

You pass an object that implements a suitable method. For example, see
java.io.File directory listing methods that have file name filter
arguments, or the sorting methods somewhere that take a comparator.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,170
Latest member
Andrew1609
Top