I need small help. I have 2 lists( say A and B) which have objects of a user defined class.
Both A and B have a method getId() which would return an integer (ID). Now, I need to compare the ID of every object in List A with each and every object of List B. If the ID is same then I have to replace that object from B with that of A.
If the id of the object from A is not in B then I would add that object to B
Please provide me a logic on how to achive this
Thanks
Something like this would work, assuming your list is an arrayList with the possibility to access elements with an index
This requiers that your elements in a and b override the equals statment, so they can compare the ID with eachother