Java Collections disjoint() MethodThe disjoint() method of Java Collections class is used to check whether two specified collections are disjoint or not. It returns true if the two specified collections have no elements in common. SyntaxFollowing is the declaration of disjoint() method: Parameter
ReturnsThe disjoint() method returns true if the two specified collections have no elements in common. ExceptionsThe disjoint() method throws the following exceptions- NullPointerException- It throws this exception if either of the collection is null or if one collection contains a null element and null is not an eligible element for the other collection. (Optional). ClassCastException- It throws this exception if one collection contains an element that is of a type which is not eligible for the other collection. (Optional). Compatibility VersionJava 1.5 and above. Example 1Test it NowOutput: Output: true Example 2Test it NowOutput: Output: false Example 3Test it NowOutput: Lists Must Have Nothing In Common! Lists Must Have Something In Common! Next TopicJava Collections Class |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India