This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes Regarding callback method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regarding callback method" Watch "Regarding callback method" New topic
Author

Regarding callback method

surya.raaj prakash
Ranch Hand

Joined: Oct 30, 2009
Posts: 76
Hi Friends,

when to use callback method(s) in java?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14117
    
  16

A callback is a general principle in programming that's used in a lot of programming languages for many different things. Ofcourse you can use this technique in Java as well.

The question "when to use this technique" is hard to answer in a general way, because there are many possible uses for it - there's not a simple and short list that says "use this for this, that and the other thing".

An example where callbacks are used is in handlers for GUI components in Swing. For example, when you call addActionListener on a JButton you pass it an implementation of ActionListener that contains a method actionPerformed, which is called by Swing when you click the button. The actionPerformed method is an example of a callback method - you pass it to Swing, and it calls the method back later.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding callback method