What are the examples of Adapter design pattern in JDK?

In JDK there are many places where Adapter design pattern is used. Some of these are as follows:

  • java.util.Arrays.asList(): This method can adapt an Array to work as a List.
  • java.util.Collections.list(): This method can adapt any collection to provide List behavior.
  • java.util.Collections.enumeration(): This method returns an enumeration over the collection.
  • java.io.InputStreamReader(InputStream): This method adapts a Stream to Reader class.
  • java.io.OutputStreamWriter(OutputStream): This method adapts an OutputStream to Writer class.
  • javax.xml.bind.annotation.adapters.XmlAdapter.marshal()

Leave a Reply

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