Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
オブジェクトのリストが 2 つあります。各リストのオブジェクトは、同じクラスの異なるサブクラスです。
リスト 1 のオブジェクトを調べて、特定のフィールドの値を確認し、リスト 2 に同じフィールド値を持つオブジェクトがあるかどうかを確認したいと考えています。これを行う最良の方法は何ですか?
これはもっと正しいと思います。これは、実装するのに最も簡単で簡単なソリューションです。
for(TypeA itemA : listA) { for(TypeB itemB : listB) { if(itemA.field == ItemB.otherField) { //Do Whatever } } }