一、new函數
調用了構造函數接口
二、反射建立class
Class myclass = Class.forName("com.company.Student"); Student student = (Student)myclass.newInstance();
調用了構造函數object
三、反序列化構造函數
ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream("d:/yld.txt")); Student student = (Student)objectInputStream.readObject();
須要實現Serializable接口,沒有調用構造函數序列化
四、clone(克隆)反射
Student student = new Student("張三",23); Student student2 = (Student)student.clone();
須要實現Cloneable接口,並重寫其clone方法,沒有調用構造函數方法