Background: there is product listing page and i have to grab all the product name (including out of stock product) and then have to verify that all out of stock product are in the end.
Problem : i have navigated all the page and stored the product names in an ArrayList.
lets say list1 and contents are -
[instant bcaa, vegan bcaa, complete bcaa energy™, branched chain amino acid (bcaa) tablets 1000mg, endure™, branched chain amino acids (bcaa), instant leucine, leucine tablets 1000mg, complete intra-workout™, leucine, bcaa jelly mix, complete hydration drink™, informed bcaa™, instant bcaa cocktail bundle]
Now i have another list which have only Out Of Stock product
list2 and contents are -
[informed bcaa™, instant bcaa cocktail bundle]
I have to make sure whether list1 has all the list2 items in the end in same sequence
retainAll()); remove all this elements (removeAll) and add them again at the end (addAll()) - eventually using a copy of the first list. Or maybe, stream-like: for every element on list2, if it is also on list1, remove it from list1 and add it to the end of list1...