Hey I have two lists of type object. I want to loop through both these lists and find the objects that have the same attribute i.e folder path so that I can combine another attribute they both have. Right now Im doing this with 2 for loops and checking for the match in the inner loop and this works. But my question is is there a more efficient way? Thanks
for(int z = 0; z < pList.size(); z++)
{
for(int c = 0; c < eList.size(); c++)
{
if(pList.get(z).path.equals(eList.get(c).path))
{
Pair rank = new Pair();
rank.k = z + c / 2.0;
rank.path = pList.get(z).path;
pcList.add(rank);
}
}
}
Sets from eachListand do aretainAllto intersect the two sets. But this assumes you have definedequalsandhashCodeto be based on yourpathattribute.