今天写了一个关于两个ArrayList的数据拷贝问题
数据源:List<JtGovInvestmentPlan> GovCapS = jtPlan.getJtGovCapPlans();
方法一:
List<JtGovInvestmentPlan> GovList =new ArrayList<JtGovInvestmentPlan>()
GovList .addAll(GovCapS );
BusCapS = GovList .stream().forEach(jt->{
jt.setGovFlag(0);
}),
//结果GovList 里的JtGovInvestmentPlan 中的GovFlag为0 ,但是GovCapS 里的JtGovInvestmentPlan 中的GovFlag也为0了,我想要的是GovCapS里的不变 ,只变GovList 里面的这个是 浅拷贝失败
方法二