VOOZH about

URL: https://www.geeksforgeeks.org/java/java-tuples-contains-method/

⇱ JavaTuples contains() method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaTuples contains() method

Last Updated : 11 Jul, 2025
The contains() method in org.javatuples is used to check whether a value 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 value in the TupleClass. Method Declaration:
public final boolean contains(Object value)
Syntax:
boolean result = TupleClassObject.contains(X value)
Parameters: This method takes value 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 is present in the tuple. Else it returns false Below programs illustrate the various ways to use contains() method: Program 1: Using contains() with Unit class: Output:
Is GeeksforGeeks present : true
Is Geeks present : false
Program 2: Using contains() with Decade class:
Output:
Is GeeksforGeeks present : true
Is Geeks present : false
Note: Similarly, it can be used with any other JavaTuple Class.
Comment
Article Tags: