How can I easily check to see whether all the elements in one ArrayList are all elements of another ArrayList?
How to check whether the elements of an ArrayList are all contained in another ArrayList
Asked Answered
boolean isSubset = listA.containsAll(listB);
is there anything available so that a new array is generated containing all data that's shared in listA and listB? Object[] subset = listA.shared(listB) –
Heliogravure
Set common = new HashSet(listA); common.retainAll(listB); // now "common" contains only the common elements –
Indian
Is there a way to check for the order of the elements as well? I tried this and it was true even though I'd changed the order of the elements. Is there a way to do what I'd like to do? –
Martino
How to check if ATLEAST ONE of the elements of a String ArrayList are contained in another String ArrayList?? –
Passionless
As this is case sensitive, how to validate for case insensitive lists? –
Exergue
© 2022 - 2024 — McMap. All rights reserved.