更新时间:2023-11-25 22:57:34
The method Collections.indexOfSubList
will give you the desired information.
返回指定源列表中指定目标列表第一次出现的起始位置,如果没有出现,则返回-1. 更正式地,返回最低索引i,这样source.subList(i,i + target.size()).equals(target)或-1(如果没有这样的索引). (如果target.size()> source.size(),则返回-1.)
Returns the starting position of the first occurrence of the specified target list within the specified source list, or -1 if there is no such occurrence. More formally, returns the lowest index i such that source.subList(i, i+target.size()).equals(target), or -1 if there is no such index. (Returns -1 if target.size() > source.size().)
int index=Collections.indexOfSubList(parentDataList, child1);
…
索引间隔将从index
(含)到index+child1.size()
(不含).当然,除非返回的索引是-1
.在后一种情况下,找不到子列表.
The index interval will be from index
, inclusive, to index+child1.size()
, exclusive. Unless the returned index is -1
, of course. In the latter case the sublist was not found.