java - Finding the same value in the list<Object>? -
here many customizablemenus objects in list, want find if 2 customizablemenus objects contains same cust.getcomponentstate(); want find getcomponentstate(); here posting code.how can value list. for(customizablemenus cust : ra.getaction().getcustomizablemenu()){ cust.getcomponentid(); cust.getcomponentidentification(); cust.getcomponentname(); cust.getcomponentstate(); custlist.add(cust); system.out.println("cust menus in ctrl custid "+ cust.getcomponentid()+"component name "+cust.getcomponentname()+"identification "+cust.getcomponentidentification()); } you have compare n items n items run loop complexity o(n^2) plus complexity of if statements: whatever using array , list , map ,.. logic same. general code: for(item item1:yourlist.getitems()){ for(item item2:yourlist.getitems()) if(item2!=item1) //not compare item it's self //if have same component state if(item2.getcompo