Here you can find the source of contains(Collection
contains(Collection, object):
checks whether the object is in object collection (create empty collection if the array is null)
Parameter | Description |
---|---|
objectArray | a parameter |
element | a parameter |
public static boolean contains(Collection<Object> objectArray, Object element)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; public class Main { /**//from w ww . j a v a 2s .com * <code>contains(Collection, object):</code> checks whether the object is in object collection * (create empty collection if the array is null) * @param objectArray * @param element * @return true if the object array has this element, false otherwise */ public static boolean contains(Collection<Object> objectArray, Object element) { /* If string array is null, create new array to avoid NullPointerException */ if (objectArray == null) { objectArray = new ArrayList<Object>(); } /* check existence */ return objectArray.contains(element); } }