Here you can find the source of contains(Collection
public static boolean contains(Collection<String> mainCollection, String str)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { public static boolean contains(Collection<String> mainCollection, String str) { String[] mainArr = new String[mainCollection.size()]; return contains(mainCollection.toArray(mainArr), str); }// www. ja va2 s. com public static boolean contains(Collection<String> mainCollection, Collection<String> subCollection) { String[] mainArr = new String[mainCollection.size()]; String[] subArr = new String[subCollection.size()]; return contains(mainCollection.toArray(mainArr), subCollection.toArray(subArr)); } public static boolean contains(String[] mainArr, String[] subArr) { for (String s : subArr) { if (!contains(mainArr, s)) { return false; } } return true; } public static boolean contains(String[] strArr, String str) { for (String s : strArr) { if (s.equals(str)) { return true; } } return false; } }