Is an actionListener a callback?

J

jmDesktop

I'm just trying to understand what a callback is. I read it is a
listener, but not sure. I have searched. Thank you for any help.
 
D

Daniele Futtorovic

I'm just trying to understand what a callback is. I read it is a
listener, but not sure. I have searched. Thank you for any help.

Pretty much. All listener can be seen as delayed callbacks.

In languages where you can have function pointers, you'd typically pass
such a pointer to a function to be used as a callback. In Java, you'll
declare the function to take a specific interface, and pass the function
an implementation of that interface. Since Java sports anonymous
classes, the process is only slightly more complicated and does
lead, in my humble opinion, to more structured and clean code than if
you could use function pointers.
 
S

Stefan Ram

jmDesktop said:
I'm just trying to understand what a callback is.

»Callback« is not a concept of the Java Language
Specification, Third Edition.

A »callback« is a callable entity that is passed
to another entity, so that this other entity might
call it (back).
 
J

jmDesktop

It depends on your definition of "callback".  In my experience, that's  
reserved for describing a function point of sorts, which Java doesn't have..

But Java does use interfaces to accomplish much the same functionality.  
In that respect, actionListener (and the numerous other similar "listener"  
interfaces) could be thought of as a "callback".

What's the context?  Where are you seeing the term "callback", and is  
there something about how it's used that you don't understand and you're  
trying to figure out?

Pete

Just in general. Nothing specific. I hate reading computer books
where they expect one to know exactly what their talking about, when
they should not suppose it. I was reading something on oop and the
author starting talking about callbacks. It was a beginner book and I
just have never really got the concept. Then I read something that
said a Java listener was a callback, which kind of cleared things up.
I can never get straight who the caller and the callee is. thanks.
 
D

Daniele Futtorovic

Just in general. Nothing specific. I hate reading computer books
where they expect one to know exactly what their talking about, when
they should not suppose it.

Sounds like you need the reference work on this subject: "How to read
computer books in forty-two days", by Ron Obvious and O.W.A. Giveaway,
Aintsinno Books, Palermo, 2001.
 

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

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top