我现在有三个List List里的对象是两个bean,我想要的条件是:list1和list2比较如果对象主键相等,累加添加到list3中。最后如果list1里的数据没有在list2中的数据,添加到list3中。如果list2没有在list1中,添加到list3中。
例:
bean1:
[code="java"]
public class Hyflightmanifest{
private String flightnumber;
private String inflag;
private Date schdate;
pirvate int num;
public String getFlightnumber() {
return flightnumber;
}
public void setFlightnumber(String flightnumber) {
this.flightnumber = flightnumber;
}
public String getInflag() {
return inflag;
}
public void setInflag(String inflag) {
this.inflag = inflag;
}
public Date getSchdate() {
return schdate;
}
public void setSchdate(Date schdate) {
this.schdate = schdate;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num= num;
}
}
[/code]
bean2:
[code="java"]
public class manifestbean{
private String flightnumber;
private String inflag;
private Date schdate;
pirvate int num;
public String getFlightnumber() {
return flightnumber;
}
public void setFlightnumber(String flightnumber) {
this.flightnumber = flightnumber;
}
public String getInflag() {
return inflag;
}
public void setInflag(String inflag) {
this.inflag = inflag;
}
public Date getSchdate() {
return schdate;
}
public void setSchdate(Date schdate) {
this.schdate = schdate;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num= num;
}
}
[/code]
[code="java"]
List maillist = cosysfightservicemailService.getBySeletive(example);
for (int i = 0; i < flightmanifestTempList.size(); i++) {
Hyflightmanifest manifestbean = new Hyflightmanifest();
manifestbean = flightmanifestTempList.get(i);
Date tempSchdate = manifestbean.getSchdate();
manifestbean.setSchdate(Tools.getDateByStr("yyyy-MM-dd", Tools.getStrByDate("yyyy-MM-dd", tempSchdate)));
for (int j = 0; j < maillist.size(); j++) {
Hycosysfightservicemail mailbean = new Hycosysfightservicemail();
if ((mailbean.getFlightnumber().trim()).equals(manifestbean.getFlightnumber().trim()) && (mailbean.getInflag().trim()).equals(manifestbean.getInflag().trim())
&& (mailbean.getActualdate().getTime() == manifestbean.getSchdate().getTime())) {
}
}
}
[/code]
[b]请问大家接着怎么做[/b]