Here you can find the source of contains(final Collection
public static <T> boolean contains(final Collection<T> c, final T o)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { public static <T> boolean contains(final Collection<T> c, final T o) { return (c != null && c.contains(o)); }//from ww w.j a va 2 s .c o m public static boolean contains(final String[] haystack, final String needle) { if (haystack != null && haystack.length != 0) { for (String straw : haystack) { if (needle.equals(straw)) { return true; } } return false; } else { return false; } } }