How can I know the different element between 2 array list in java? I need the exact element not a Boolean value which can be retrieved using removeAll()
.
LinkedHashMap table;
for each element e of array A
if table.get(e) != null
table.put( e, table.get(e) + 1 )
else
table.put( e, 0 )
//Do the same for array B
for each element e of array B
if table.get(e) != null
table.put( e, table.get(e) + 1 )
else
table.put( e, 0 )
At the end of the for loops elements in table with value=0 are the different ones.