This tutorial Adapter Design Pattern in Java, Adapter Pattern converts the interface of a class into another interface the clients expects. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.


We have a database access class which provides the access to database tables and returns the data. This data should be displayed in a tree widget. The table expects the data to be provided via a certain interfaces. Instead of adding this interface to the database access class (which would couples the GUI coding very tight to the database access class), we develop an adapter which converts the interfaces of the database access class to the interfaces of the tree.


By implementing an interface we can replace the adapter and or the underlying model easily which another adapter / model. Hence the application is loosely coupled.

Adapter allows to reuse existing coding without changing it. The adapter will make the conversion between the interfaces.

In comparison to a decorator the adapter pattern only converts interfaces, while the decorator pattern adds new functionality to an existing interface. Therefore the decorator does not change the existing interface.

One thought on “Adapter Design Pattern in Java

Leave a Reply

Your email address will not be published. Required fields are marked *