java - How to check whether a list is a subset of another list -
this question has answer here:
- get index of contain sublist list java 3 answers
list1:[1,2,3,4,5] list2:[1,2,3]
how check if list2 subset of list1? tried containsall() gives true long elements in list 2 present in list1. want same order criteria , not elements.
use this:
boolean contains(list<?> list, list<?> sublist) { return collections.indexofsublist(list, sublist) != -1; }
Comments
Post a Comment