The concept of callback function does not exist in Java, because in Java there are no functions, only object methods. However, there are situations when you can talk about a callback object or callback interface .
For example, when you call an ArrayList object to sort, and you supply a comparator that knows how to compare the objects contained in the list, your code is a high level level that calls a lower level (a standard java runtime list object), providing it with an interface to an object that is at your (high level) level. Then the list will "redirect" your object to complete the part of the task that does not know how to do this, namely, compare the elements of the list. Thus, in this case, the comparator can be considered as a callback object.
Mike Nakis Jan 05 2018-12-01T00: 00Z
source share