Remove Only One Item from a List (Android)

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Remove Only One Item from a List (Android)



I have a list: (x, y, y,z)


(x, y, y,z)



I have another list: (x, y)


(x, y)



You want to remove the items from the 1st list that belong also in the 2nd list.



Ex: I want the result to be (y,z)


(y,z)



How do I do this?



EDIT: If I use removeAll. The example list returns (z)





You want to remove the items from the 1st list that belong also in the 2nd list. Edit your question.
– mTak
7 mins ago





Does order matter? For example, if the second list was (y, x) would you want the same outcome?
– Tyler V
4 mins ago





The result will be (z) not (y,z)
– mTak
3 mins ago





Guys, its simple. I don't want it to remove y twice.
– Ron Arel
2 mins ago





And the result is z
– Ron Arel
2 mins ago




1 Answer
1



You can use remove all


List<String> one = new ArrayList<String>();
one.add("x");
one.add("y");
one.add("y");
one.add("z");
List<String> two = new ArrayList<String>();
two.add("x");
two.add("y");
one.removeAll(two);
System.out.println(one);





If I removeAll. The example list returns (z)
– Ron Arel
8 mins ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

ssxEge3uFxMdk5 pe,Yy05tUwBgNok,D,PSz Axj7a,8W zSOukHwC,qVwaEPaXOIK,1blYH8j9BuhwHAe0LYKSAFt3dEsCvdnk,E
IfBPHpi5ji,UKCX F 8La,uIn16IrLdszMcDqpM,ri j 9Om RSN,9yE2KZ9ynIS9YN,wxSY1KSvPqx

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham