Классы:
Код: Выделить всё
public class TypeOne {
private int id;
}
Код: Выделить всё
public class TypeTwo {
private int id;
}
Код: Выделить всё
Collection oneColl = someMethodToPopulateThat();
Collection twoColl = anotherMethodToPopulateThat();
// Iterating both collections to match the elements by id
for(TypeOne one : oneColl) {
for(TypeTwo two : twoColl) {
if (one.getId().equals(two.getId()))
System.out.println(one.getId());
}
}
Есть ли у кого-нибудь идеи, как решить эту проблему?
Подробнее здесь: https://stackoverflow.com/questions/686 ... of-objects
Мобильная версия