java - How to check whether a list is a subset of another list -


this question has answer here:

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;   } 

http://docs.oracle.com/javase/7/docs/api/java/util/collections.html#indexofsublist(java.util.list,%20java.util.list)


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -