The containsAll() method in org.javatuples is used to check whether a collection of values is present in the TupleClass, given as parameters. This method can be used for any tuple class object of the javatuples library. It returns a boolean value that is true or false based on the presence of that collection of values in the TupleClass.
public final boolean containsAll(Object... value)
boolean result = TupleClassObject.containsAll(X value1, X value2, ...) OR boolean result = TupleClassObject.containsAll(X values)
Parameters: This method takes value or values as parameter where:
- X– represents the datatype of values in the parameter.
- TupleClassObject– represents the JavaTuple Class object used like Unit, Quintet, Decade, etc.
Return Value: This method returns true if the parameter value are present in the tuple. Else it returns false
Below programs illustrate the various ways to use containsAll() method:
Program 1: Using containsAll() with Unit class:
Is [GeeksforGeeks] present : true Is [Geeks, for, Geeks] present : false
Program 2: Using containsAll() with Decade class:
Is [Geeks, for, Geeks] present : true Is [Geeks, not, for, Geeks] present : false
Note: Similarly, it can be used with any other JavaTuple Class.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.