0
假設我有這兩個ArrayLists
,第一個是ObjectA
,第二個ObjectB
。如何關聯兩個對象的ArrayList?
這些對象A的變量:
int id;
double value;
而這些對象B的變量:
int objAId;
double disccountValue;
我如何可以檢索對象B的disccountValue
其中objAId
相同項目的第一行了?就像在SQL查詢中一樣,但是在ArrayLists
中。
循環擺脫外的一個ID,也許 ? –
[將兩個arrayLists合併成一個新的arrayList,沒有重複和按順序,在Java]可能重複(http://stackoverflow.com/questions/9917787/merging-two-arraylists-into-a-new-arraylist- with-no-duplicates-and-in-order-in) – jsoberg
您可以重寫equals方法,並獲取包含該值的對象索引。 ()和indexOf() –