newInstance() and new


同じ点
newInstance()  and new can both create new object.
 
異なる点
newInstance() must follow by forName(className), and the class is loaded
弱いタイプ.非効率.非パラメトリック構造のみを呼び出すことができます.
 
class with new will loaded only when called
強いタイプ.相対的に効率的です.任意のpublic構造を呼び出すことができます
 
 
newInstance simple use
String className = "Example";class c = Class.forName(className);factory = (ExampleInterface)c.newInstance();
 
JDBC case
Class.forName(driverClassName);
someones followed the newInstance(), actually no need.
 
// Driver will register to DriverManager in static block
			 public class MyJDBCDriver implements Driver {
			 static {
			 DriverManager.registerDriver(new MyJDBCDriver());
			 }
 
Q:newInstance exception handle?