In general, this communication is done through Callback functions. In Java, callbacks are supported by interfaces. An inner class is a class defined inside another class. Inner classes can be hidden from other classes in the same package. Anonymous inner classes are handy to define callback functions on the fly.
Inner classes are convenient for writing event-driven programs.
As an example, a property editor is use to show how inner classes can be used. A property editor is an editor that allows the user to modify the properties of given objects. First an interface is needed. Using an Inner Class to Implement the Property Interface As an example, salary and seniority properties are added to the Employee class used in previous examples to illustrate the use of inner classes. Note that only inner classes can be private.