import java.lang.reflect.Field;
public class util {
//只能用在用户自定的类上,不可以用在包装类,基础数据类型;
//包装类 是深拷贝。不是拷贝地址
public static <T> void cope(T source,T target){
Field[] fie=source.getClass().getDeclaredFields();
for(Field temp :fie) {
temp.setAccessible(true);
try {
temp.set(target, temp.get(source));
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
包装类 是深拷贝。不是拷贝地址。