Most people believe that the meaning of the interface is that the replacement multiple inheritance. It is well known that Java does not have a mechanism such as C , but it is capable of playing multiple interfaces. In fact, this is a very strong, interface and inheritance is completely different, and the interface has no ability to replace multiple inheritance, and there is no obligation. The role of the interface is, which is the class of the flag class (Type of class). Attributing different types of classes to different interfaces, can manage them better. OO's essence, I thought it was an abstraction of the object, and the most embodied is the interface. Why do we discuss design patterns only for languages with abstract abilities (such as C , Java, C #, etc.), because of the design mode, it is actually reasonable to abstract. (Cowboy's famous is "Abstract is part of the like", seemingly ridiculed, actually even). The most basic in design model is factory mode. In my recent simple app, I want to make my program to transplant in multiple databases. Of course, this involves many problems. How is the order? Compatible with SQL of DBMS is a headache. We may wish to simplify the problem first, just consider how to connect different databases. Suppose I have a lot of classes, named Mysql.java, SQLServer.java, Oracle.java, DB2.java, which connects different databases, and returns a Connection object, and there is a Close method for closing the connection. Just need for your dbms, choose different classes, you can use it, but what database he will use? I don't know, I hope that I can meet the needs of the code as little as possible. I can abstract the following interface: package org.bromon.test; public interface db {java.sql.connection OpenDB (String Url, string user, string password); void close ();} This interface only defines two methods, no any There is a practical code, the specific code is given by the class of the actual interface, such as mysql.java: post org.bromon.test; import java.sql. *; Public class mysql imports db {private string url = " JDBC: mysql: localhost: 3306 / test "; private string user =" root "; private string password ="; private connection "{// connection database code} PUBLIC VOID Close () {// Turns the database}} There are of course Oracle.java, etc. MYDB to manipulate the database, you can actually do what kind of class I am using, this is the so-called "open-closed" principle. But the problem is that the interface cannot be instantiated, mydb = new db (), such code is absolutely wrong, we can only myDB = new mysql () or mydb = new oracle ().