Should we use clone or BeanUtils.copyProperties and why

前端 未结 7 1738
醉话见心
醉话见心 2020-12-13 04:47

By the looks of it - BeanUtils.copyProperties seems to create a clone of an object. If this is the case, and what with the concerns around implementing the Clon

7条回答
  •  暖寄归人
    2020-12-13 05:08

    clone creates a shallow copy of the object, the clone object is always of the same class as the original one. All fields, private or not are copied.

    BeanUtils.copyProperties API Copy property values from the origin bean to the destination bean for all cases where the property names are the same.

    As to me, these two concepts have little in common.

提交回复
热议问题