我需要按对象的 id 合并数组。我的班级有两个数组(本地和全局):
public class Info {
private int id;// never change
private String msg;
private boolean isFavor;// presents only in local array
// constructor,getters, setters etc
}
合并规则:
如果对象不存在于全局数组中,我们不合并它;
仅从全局对象中获取 msg ;
如果对象存在于全局数组中,我们添加(合并)它;
变量“isFavor”取自本地对象;
数组没有排序;
例子:
local arayList = {Info(1,"msg1",false),Info(2,"msgTwo",false),Info(3,"msg3",true), Info(4,"msg4",true)};
global arayList = {Info(1,"msg1",false),Info(2,"msg2",false),Info(3,"msg3",false),Info(5,"msg5",false)}
result arayList = {Info(1,"msg1",false),Info(2,"msg2",false),Info(3,"msg3",true),Info(5,"msg5",false)}
慕勒3428872
鸿蒙传说
相关分类