java - ArrayList of objects. Search by multiple conditions -
i've got arraylist of crm objects (actionslist). want find: if 1 object has value "first contact" in field "typeofcontact", there object value "offer" field "typeofcontact" , same dealer , name in previous object.
public class crm { private string remark; private string number; private string dealer; private string name; private string typeofcontact; private string model; private string phone; private string email; //... public string getremark(){ return remark; } public void setremark(string remark){ this.remark=remark; } public string getnumber(){ return number; } public void setnumber(string number) { this.number=number; } public string getdealer(){ return dealer; } public void setdealer(string dealer) { this.dealer=dealer; } public string getname(){ return name; } public void setname(string name) { this.name=name; } public string gettypeofcontact(){ return typeofcontact; } public void settypeofcontact(string typeofcontact) { this.typeofcontact=typeofcontact; } public string getmodel(){ return model; } public void setmodel(string model) { this.model=model; } public string getphone(){ return phone; } public void setphone(string phone) { this.phone=phone; } public string getemail(){ return email; } public void setemail(string email) { this.email=email; } // ... }
should this?
for(crm crm : actionslist){ if (crm.gettypeofcontact.equals("first contact"){ for(crm x : actionslist){ if (x.getdealer().equals(crm.getdealer()) && (x.getname().equals(crm.getname()) && x.gettypeofcontact().equals("offer"))){ system.out.println("ok"); } else { system.out.println("not ok"); } } } }
your methods functions , require ()
, this
if (x.getdealer.equals(crm.getdealer) && (crm.getdealer.equals(crm.getdealer) && (x.getname.equals(crm.getname) && (x.gettypeofcontact.equals("offer"){
and have dangling parenthesis, , crm.getdealer.equals(crm.getdealer)
makes no sense - removed that. think wanted like,
if (x.getdealer().equals(crm.getdealer()) && (x.getname().equals(crm.getname()) && x.gettypeofcontact().equals("offer"))){
Comments
Post a Comment