I have a list<P> (java.util.list) .
Now I want to replace elements in list<A> based on two conditions.
If element == 'a' replace with 'x' and if element == 'b' replace with 'y'. x and y are of type Q.
What is the cleanest / efficient way to do this? Preferably, I do not want to iterate using a for loop. I can use a stream/replaceAll but that would mean violating the type of the list.
List<P>into aList<A>or similar.