Considerations for taking unions in sets

In the projects we often do, we may encounter whether a collection contains data in another collection, then the problem arises. There is a method in the list collection called contains.

The following is a detailed introduction in the api

<!-- Generated by javadoc (build 1.6.0-beta2) on Fri Mar 09 12:52:05 CST 2007 -->

<noscript></noscript>
boolean contains(Object o)
Returns true if the list contains the specified element . More precisely, returns true if and only if the list contains an element e that satisfies (o==null ? e==null : o.equals(e)) .
Designator:
in the interface Collection<E> contains
parameter:
o - the element to test for existence in the list
return:
Returns true if the list contains the specified element
throws:
ClassCastException - if the type of the specified element is incompatible with this list (optional)
NullPointerException - if the specified element is null and this list does not allow null elements (optional)
Returns true if the collection contains,
However, it should be noted that when using this method, you must take care. The generic types of lists must be the same to determine whether they contain

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326175346&siteId=291194637