I’m trying to check if an id from one class already exists in the other for example:
Class pin{
String id;
int amount;
}
Class pinCol{
String id;
String name;
}
this is just an example to show there are two classes that both have an id value but the other values differ.
now I want to see if the new ids of the first are still the same as the IDs in the second without deleting all the values and just replacing them.
for example, I want to see if the id’s in pins is still the same as the id’s in pinCol, any new ids I want to add and any ids that exist in pinCol and not in pins I want to remove from pinCol
2
Answers
Assuming
pins
is a list ofpin
objects andpinCols
is a list ofpinCol
objects, you could do this to remove all pinCols that don’t have an id that it’s in the list of pins:What are you trying to achieve?
If you have to match the value then the key name should be different otherwise it’s overridden.
If Both class key names are the same then the value will be overridden. Like below example
Example
Maybe it’ll help for you.