Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • 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
  • 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:
LinkedBlockingDeque equals() method in Java with Example
Next article icon

LinkedBlockingDeque equals() method in Java with Example

Last Updated : 24 Dec, 2018
Comments
Improve
Suggest changes
Like Article
Like
Report
The equals() method of java.util.LinkedBlockingDeque class is used to compare the specified object with this LinkedBlockingDeque for equality. Returns true if and only if the specified object is also a LinkedBlockingDeque, both LinkedBlockingDeques have the same size, and all corresponding pairs of elements in the two LinkedBlockingDeques are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, two LinkedBlockingDeques are defined to be equal if they contain the same elements in the same order. Syntax:
public boolean equals(Object o)
Parameters: This method takes the object o as a parameter to be compared for equality with this LinkedBlockingDeque. Returns Value: This method returns true if the specified object is equal to this LinkedBlockingDeque. Below examples illustrates the LinkedBlockingDeque.equals() method: Program 1: Java
// Java Program Demonstrate equals() // method of LinkedBlockingDeque  import java.util.concurrent.LinkedBlockingDeque; import java.util.*;  public class GFG {     public static void main(String[] args)         throws IllegalStateException     {          // create object of LinkedBlockingDeque         LinkedBlockingDeque<Integer> LBD1             = new LinkedBlockingDeque<Integer>();          // Add numbers to end of LinkedBlockingDeque         LBD1.add(7855642);         LBD1.add(35658786);         LBD1.add(5278367);         LBD1.add(74381793);          System.out.println("Linked Blocking Deque 1: " + LBD1);          // create another object of LinkedBlockingDeque         LinkedBlockingDeque<String> LBD2             = new LinkedBlockingDeque<String>();          // Add numbers to end of LinkedBlockingDeque         LBD2.add("1");         LBD2.add("2");         LBD2.add("3");         LBD2.add("4");          System.out.println("Linked Blocking Deque 2: " + LBD2);          // using equals() function         System.out.println("Are both Linked Blocking Deque equal: "                            + LBD1.equals(LBD2));     } } 
Output:
  Linked Blocking Deque 1: [7855642, 35658786, 5278367, 74381793]  Linked Blocking Deque 2: [1, 2, 3, 4]  Are both Linked Blocking Deque equal: false  
Program 2: Java
// Java Program Demonstrate equals() // method of LinkedBlockingDeque // when the list contains characters  import java.util.concurrent.LinkedBlockingDeque; import java.util.*;  public class GFG {     public static void main(String[] args)         throws IllegalStateException     {          // create object of LinkedBlockingDeque         LinkedBlockingDeque<String> LBD1             = new LinkedBlockingDeque<String>();          // Add numbers to end of LinkedBlockingDeque         LBD1.add("1");         LBD1.add("2");         LBD1.add("3");         LBD1.add("4");          System.out.println("Linked Blocking Deque 1: " + LBD1);          // using equals() function         System.out.println("Is LBD1 equal to LBD1: "                            + LBD1.equals(LBD1));     } } 
Output:
  Linked Blocking Deque 1: [1, 2, 3, 4]  Is LBD1 equal to LBD1: true  

Next Article
LinkedBlockingDeque equals() method in Java with Example

C

code_r
Improve
Article Tags :
  • Java
  • Java-Collections
  • Java - util package
  • Java-Functions
  • Java-LinkedBlockingDeque
Practice Tags :
  • Java
  • Java-Collections

Similar Reads

    LinkedBlockingDeque putFirst() method in Java
    The putFirst(E e) method of LinkedBlockingDeque inserts the specified element at the front of the queue represented by this deque. If the Deque is capacity restricted, then it will wait for the space to become available. Syntax: public void putFirst(E e) Parameters: This method accepts a mandatory p
    2 min read
    LinkedBlockingDeque removeFirst() method in Java
    The removeFirst() method of LinkedBlockingDeque returns and removes the first element of the Deque container from it. The method throws an NoSuchElementException if the Deque container is empty. Syntax: public E removeFirst() Returns: This method returns the head of the Deque container, which is the
    2 min read
    LinkedBlockingDeque remainingCapacity() method in Java
    The remainingCapacity() method of LinkedBlockingDeque returns the number of additional elements that this deque can ideally (in the absence of memory or resource constraints) accept without blocking. remainingCapacity() = final_size() - current_size() Syntax: public int remainingCapacity() Parameter
    2 min read
    LinkedBlockingDeque size() method in Java
    The size() method of LinkedBlockingDeque returns the current size of the Deque container. On calling the function the number of elements in the Deque container is returned. If the container is capacity restricted, then also it returns the number of elements which are present in the container at the
    2 min read
    LinkedBlockingDeque spliterator() method in Java
    The spliterator() method of LinkedBlockingDeque returns a Spliterator on the elements of LinkedBlockingDeque. The returned iterator is weakly consistent. Spliterator can be used with Streams in Java 8. Spliterator can traverse elements individually and in bulk too. Syntax: public Spliterator spliter
    2 min read
    LinkedBlockingDeque removeFirstOccurrence() method in Java
    The removeFirstOccurrence() method of LinkedBlockingDeque removes the first occurrence of the specified element from this deque. If the deque does not contain the element, it remains unchanged. It returns true if this deque contained the specified element, else it returns false. Syntax: public boole
    2 min read
    LinkedBlockingDeque takeLast() method in Java
    The takeLast() method of LinkedBlockingDeque returns and removes the tail of the Deque container from it. The method throws an InterruptedException if it is interrupted while waiting. Syntax: public E takeLast() Returns: This method returns the tail(last element) of the Deque container. Exception: T
    2 min read
    LinkedBlockingDeque take() method in Java
    The take() method of LinkedBlockingDeque returns and removes the head of the Deque container from it. The method throws an InterruptedException if it is interrupted while waiting. Syntax: public E take() Returns: This method returns the head of the Deque container. Exception: The function throws a I
    2 min read
    LinkedBlockingDeque removeLastOccurrence() method in Java
    The removeLastOccurrence() method of LinkedBlockingDeque removes the last occurrence of the specified element from this deque. If the deque does not contain the element, it remains unchanged. It returns true if this deque contained the specified element, else it returns false. Syntax: public boolean
    2 min read
    LinkedBlockingDeque takeFirst() method in Java
    The takeFirst() method of LinkedBlockingDeque returns and removes the first element of the Deque container from it, waiting if necessary until an element becomes available.. The method throws an InterruptedException if it is interrupted while waiting. Syntax: public E takeFirst() Returns: This metho
    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