java 将对象数据复制到另一个对象中

import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;

Car newItem = new Car();

Car newOld = new Car();

try {
BeanUtils.copyProperties(newItem, newOld );
} catch (IllegalAccessException | InvocationTargetException e) {
 //
}

这样newItem 中就有newOld 相关的数据了

posted @ 2021-09-09 17:34  小小菜鸟04  阅读(1592)  评论(0)    收藏  举报