Abstract Factory mode: defines an interface for creating an object, so that the subclass decides which class to instantiate. One of the advantages of the abstract factory model is that it complies with the "open-closed" principle, that is, the modification is closed and the extension is open. Compared with the simple factory mode, the abstract factory mode does not place the object generation in the factory class, but in the factory subclass. To add an object, you only need to add the class of the object and add the factory of the generated object. You do not need to modify the original code. Abstract Factory class diagram: public interface Fruit {public abstract void eat (String sun, String water);} public interface Factory {public abstract Fruit getFruit ();} public class Apple implements Fruit {public void eat (String sun, String water) {}} public class AppleFactory implements Factory {public Fruit getFruit () {return new Apple ();}} public class Bananas implements Fruit {public void eat (String sun, String water) {}} public class BananasFactory implements Factory {public Fruit getFruit () {return new Bananas ();}} public class Client {public static void main (String [] args) {Fruit apple = new AppleFactory (). getFruit (); apple. eat ("Sunshine", "water"); Fruit bananas = new BananasFactory (). getFruit (); bananas. eat ("Sunshine", "water ");}}