- What is adaptor pattern in Java?
- What is adapter design pattern with example?
- What is Adapter pattern give real life example?
- When to use adapter design pattern in Java?
What is adaptor pattern in Java?
An Adapter pattern acts as a connector between two incompatible interfaces that otherwise cannot be connected directly. An Adapter wraps an existing class with a new interface so that it becomes compatible with the client's interface.
What is adapter design pattern with example?
This pattern involves a single class which is responsible to join functionalities of independent or incompatible interfaces. A real life example could be a case of card reader which acts as an adapter between memory card and a laptop.
What is Adapter pattern give real life example?
One of the great real life example of Adapter design pattern is mobile charger. Mobile battery needs 3 volts to charge but the normal socket produces either 120V (US) or 240V (India). So the mobile charger works as an adapter between mobile charging socket and the wall socket.
When to use adapter design pattern in Java?
In design, adapters are used when we have a class (Client) expecting some type of object and we have an object (Adaptee) offering the same features but exposing a different interface. To use an adapter: The client makes a request to the adapter by calling a method on it using the target interface.