Java Annotations are also called Metadata. Annotations are introduced with JDK 5 onwards. Annotations allows us to add some form of metadata information into our source code, but it doesnot change the execution flow of the program. These annotations can then be processed at compile time by the compiler tools or during at runtime via Java Reflection. Classes, methods, variables may be annotated.
An adapter class is an implementation class of a listener interface which contains all methods implemented with empty body. for example,WindowAdapter is an adapter class of WindowListener interface.Adapter classes reduce overhead on programming while working with listener interfaces.
Many listener interfaces have more than one callback method. An example is, even the code of myclass can be copied directly into addwindowListener() method,as:
public void windowClosing(windowEvent e)
To avoid having many empty listener methods for many listeners, Adapter classes are provided. These implement the listener interface, and provide empty (no operation) implementation of its methods. The advantage is that the listener can extend these, and only specialize methods of choice without having to provide default implementations for the rest (these are inherited from the Adapter).