1.使用new关键字
2.使反射进行
a 通过Class类的newInstance方法 -> Class.forname().newInstance();
b 通过Constructor类的newInstance方法 ->
Constructor constructor = Employee.class.getConstructor();
Employee emp3 = constructor.newInstance();
3.使用clone(克隆)方法
4.使用反序列化
创建对象的4种方式?
猜你喜欢
转载自blog.csdn.net/weixin_41980692/article/details/105720954
今日推荐
周排行