Java不同的方法创建对象的区别
new
MyObject object = new MyObject();
Class.forName()
MyObject object = (MyObject) Class.forName("subin.rnd.MyObject").newInstance();
clone()
MyObject anotherObject = new MyObject();
MyObject object = (MyObject) anotherObject.clone();
object deserialization
ObjectInputStream inStream = new ObjectInputStream(anInputStream );
MyObject object = (MyObject) inStream.readObject();
Loading...