Abstract Factory: offers the interface for creating a family of related objects, without explicitly specifying their classes. We can simply say that it is higher level of abstraction of factory pattern.
Examples –
Used in jdk as:
java.util.Calendar#getInstance()
java.util.Arrays#asList()
java.util.ResourceBundle#getBundle()
java.net.URL#openConnection()
java.sql.DriverManager#getConnection()
java.sql.Connection#createStatement()
java.sql.Statement#executeQuery()
java.text.NumberFormat#getInstance()
java.lang.management.ManagementFactory
(all getXXX() methods)java.nio.charset.Charset#forName()
javax.xml.parsers.DocumentBuilderFactory#newInstance()
javax.xml.transform.TransformerFactory#newInstance()
javax.xml.xpath.XPathFactory#newInstance()
Prototype : Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.
Used in jdk:
-
java.lang.Object#clone() (the class has to implement java.lang.Cloneable)