Here you can find the source of containsExactly(List
public static <T> boolean containsExactly(List<T> items, T... itemsToMatch)
//package com.java2s; import java.util.List; public class Main { public static <T> boolean containsExactly(List<T> items, T... itemsToMatch) { if (items.size() != itemsToMatch.length) { return false; }//from w ww . jav a 2 s .c o m for (int i = 0; i < items.size(); i++) { if (!items.get(i).equals(itemsToMatch[i])) { return false; } } return true; } }