Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Java Arrays
  • Java Strings
  • Java OOPs
  • Java Collection
  • Java 8 Tutorial
  • Java Multithreading
  • Java Exception Handling
  • Java Programs
  • Java Project
  • Java Collections Interview
  • Java Interview Questions
  • Java MCQs
  • Spring
  • Spring MVC
  • Spring Boot
  • Hibernate
Open In App
Next Article:
JavaTuples containsAll() method
Next article icon

JavaTuples equal() method

Last Updated : 09 Nov, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

The equals() method in org.javatuples is used to check whether a TupleClass is equal to the TupleClass given as parameter. This method can be used to any tuple class object of javatuples library. It returns a boolean value that is true or false based on the equivalence of that TupleClass with existing TupleClass. Method Declaration:

public final boolean equals(Object obj)

Syntax:

boolean result = TupleClassObject.equals(TupleClass2Object)

Parameters: This method takes TupleClass2Object as parameter where:

  • TupleClassObject- represents the JavaTuple Class object used like Unit, Quintet, Decade, etc.
  • TupleClass2Object- represents the parameter passed JavaTuple Class object used like Unit, Quintet, Decade, etc.

Return Value: This method returns true if the TupleClassObject is equal to the TupleClass2Object. Else it returns false Below programs illustrate the various ways to use equals() method: Program 1: Using equals() with Unit class: 

Java
// Below is a Java program to use equals() method  import java.util.*; import org.javatuples.Unit;  class GfG {     public static void main(String[] args)     {         // Creating an Unit with one value         Unit<String> unit = Unit.with("GeeksforGeeks");          // Creating another Unit with one value         Unit<String> unit1 = Unit.with("GeeksNotforGeeks");          // Using equals() method         boolean res = unit.equals(unit1);          System.out.println("Is " + unit + " equal to "                            + unit1 + " : " + res);     } } 

Output:

Is [GeeksforGeeks] equal to [GeeksNotforGeeks] : false

Program 2: Using equals() with Quartet class: 

Java
// Below is a Java program to use equals() method  import java.util.*; import org.javatuples.Quartet;  class GfG {     public static void main(String[] args)     {         // Creating Quartet from List         List<String> list = new ArrayList<String>();         list.add("GeeksforGeeks");         list.add("A computer portal");         list.add("for geeks");         list.add("by Sandeep Jain");          Quartet<String, String, String, String> quartet             = Quartet.fromCollection(list);          // Creating Quartet from Array         String[] arr = { "GeeksforGeeks",                          "A computer portal",                          "for geeks",                          "by Sandeep Jain" };          Quartet<String, String, String, String> otherQuartet             = Quartet.fromArray(arr);          // Using equals() method         boolean res = quartet.equals(otherQuartet);          System.out.println("Is \n" + quartet + "\n equal to \n"                            + otherQuartet + "\n : " + res);     } } 

Output:

Is  [GeeksforGeeks, A computer portal, for geeks, by Sandeep Jain]  equal to  [GeeksforGeeks, A computer portal, for geeks, by Sandeep Jain]  : true

Note: Similarly, it can be used with any other JavaTuple Class.


Next Article
JavaTuples containsAll() method

R

RishabhPrabhu
Improve
Article Tags :
  • Java
  • Java-Functions
  • JavaTuples
Practice Tags :
  • Java

Similar Reads

  • Java Map equals() Method
    The equals() method of Map interface in Java is used to check if two maps are equal. Two maps are considered equal if they meet the following conditions. Both maps must have the same size.Both maps must contain identical key-value pairs. (It means every key in one map must be associated with the sam
    2 min read
  • JavaTuples hashcode() method
    The hashCode() method in org.javatuples method returns the hash code for the JavaTuple class object. The hashcode is always the same if the object doesn't change. Hashcode is a unique code generated by the JVM at time of object creation. It can be used to perform some operation on hashing related al
    2 min read
  • JavaTuples contains() method
    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 TupleC
    2 min read
  • JavaTuples containsAll() method
    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 c
    2 min read
  • JavaTuples compareTo() method
    The compareTo() method in org.javatuples is used to compare the order of a Tuple object with the object passed as the parameter. This method can be used for any tuple class object of javatuples library. It returns the difference in the ASCII value of the 1st different element present in the passed o
    2 min read
  • Set equals() Method in Java
    In Java, the equals() method of the Set class is used to compare two sets for equality. It checks if two sets contain the same elements regardless of their order. Example 1: This example demonstrates how to compare two HashSet collections for equality of type string using the equals() method. [GFGTA
    2 min read
  • LongBuffer equals() method in Java
    The equals() method of java.nio.LongBuffer Class is used to check whether or not the given buffer is equal to another object. Two Long buffers are equal if, and only if, They have the same element type, They have the same number of remaining elements, and The two sequences of remaining elements, con
    4 min read
  • MathContext equals() Method in Java
    The java.math.MathContext.equals() is an in-built function in Java which checks for equality between this MathContext object with the object passed as parameter to the function. The function returns true if the context settings of both the aforementioned objects are same. Syntax : public boolean equ
    2 min read
  • Vector equals() Method in Java
    The java.util.vector.equals(Object obj) method of Vector class in Java is used verify the equality of an Object with a vector and compare them. The list returns true only if both Vector contains same elements with same order. Syntax: first_vector.equals(second_vector) Parameters: This method accepts
    2 min read
  • Java AbstractSet equals() Method
    The AbstractSet equals() Method in Java is used to check for equality between two sets. This method verifies whether the elements of one set are equal to the elements of another set. Syntax of AbstractSet equals() Methodpublic boolean equals(Object o) Parameter: The object "o" is to be compared for
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences