newInstance() uses the class loading mechanism, and new creates a new class.
From a JVM perspective, when using new to create a class, the class may not be loaded. But when using the newInstance() method, you must ensure that the class is loaded and the class is connected.
Copy the code code as follows:
String className="test";
Class c=Class.forName(className);
factory=(ExampleInterface)c.newInstance();
newInstance():if type. Inefficient, only the no-argument constructor can be called, suitable for factory mode;
new: Strong type. Relatively efficient. Can call any public constructor