1、使用new关键字创建对象
MyObject obj = new MyObject();
2、使用Class类中的newInstance()方法创建对象
MyObject obj = (MyObject) Class.forName("com.example.MyObject").newInstance();
3、使用Constructor类的newInstance方法创建对象
Constructor<MyObject> constructor = MyObject.class.getConstructor();
MyObject obj = constructor.newInstance();
4、使用clone()方法创建对象
MyObject obj1 = new MyObject();
MyObject obj2 = obj1.clone();
5、使用反序列化创建对象
ObjectInputStream in = new ObjectInputStream(new FileInputStream("object.ser"));
MyObject obj = (MyObject) in.readObject();