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:
LinkedBlockingDeque peekFirst() method in Java
Next article icon

LinkedBlockingDeque descendingIterator() method in Java

Last Updated : 14 Sep, 2018
Comments
Improve
Suggest changes
Like Article
Like
Report

The descendingIterator() method of LinkedBlockingDeque returns an iterator over the elements in this deque in a reverse sequential order. The elements will be returned in order from last(tail) to first(head). The returned iterator is a “weakly consistent” iterator.

Syntax:

public Iterator descendingIterator()

Parameters: This method does not accept any parameter.

Returns: This method returns an iterator over the elements in this deque in a reverse sequential order.

Below programs illustrate descendingIterator() method of LinkedBlockingDeque:

Program 1:




// Java Program Demonstrate descendingIterator()
// method of LinkedBlockingDeque
  
import java.util.concurrent.LinkedBlockingDeque;
import java.util.*;
  
public class GFG {
    public static void main(String[] args)
  
    {
  
        // create object of LinkedBlockingDeque
        LinkedBlockingDeque<Integer> LBD
            = new LinkedBlockingDeque<Integer>();
  
        // Add numbers to front of LinkedBlockingDeque
        LBD.addFirst(7855642);
        LBD.addFirst(35658786);
        LBD.addFirst(5278367);
        LBD.addFirst(74381793);
  
        // Call descendingIterator() method of LinkedBlockingDeque
        Iterator iteratorVals = LBD.descendingIterator();
  
        // Print elements of iterator
        // created from PriorityBlockingQueue
        System.out.println("The iterator values"
                           + " of LinkedBlockingDeque are:");
  
        // prints the elements using an iterator
        while (iteratorVals.hasNext()) {
            System.out.println(iteratorVals.next());
        }
    }
}
 
 
Output:
  The iterator values of LinkedBlockingDeque are:  7855642  35658786  5278367  74381793  

Program 2:




// Java Program Demonstrate descendingIterator()
// method of LinkedBlockingDeque
// when list is of strings
  
import java.util.concurrent.LinkedBlockingDeque;
import java.util.*;
  
public class GFG {
    public static void main(String[] args)
  
    {
  
        // create object of LinkedBlockingDeque
        LinkedBlockingDeque<String> LBD
            = new LinkedBlockingDeque<String>();
  
        // Add numbers to front of LinkedBlockingDeque
        LBD.add("Geeks");
        LBD.add("forGeeks");
        LBD.add("A");
        LBD.add("Computer");
        LBD.add("Portal");
  
        // Call iterator() method of LinkedBlockingDeque
        Iterator iteratorVals = LBD.descendingIterator();
  
        // Print elements of iterator
        // created from PriorityBlockingQueue
        System.out.println("The iterator values"
                           + " of LinkedBlockingDeque are:");
  
        // prints the elements using an iterator
        while (iteratorVals.hasNext()) {
            System.out.println(iteratorVals.next());
        }
    }
}
 
 
Output:
  The iterator values of LinkedBlockingDeque are:  Portal  Computer  A  forGeeks  Geeks  

Reference: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/LinkedBlockingDeque.html#descendingIterator()



Next Article
LinkedBlockingDeque peekFirst() method in Java
author
gopaldave
Improve
Article Tags :
  • Java
  • Java - util package
  • Java-Collections
  • Java-Functions
  • Java-LinkedBlockingDeque
Practice Tags :
  • Java
  • Java-Collections

Similar Reads

  • LinkedBlockingDeque add() method in Java
    The add(E e) method of LinkedBlockingDeque inserts the element passed in the parameter to the end of the Deque is there is space. If the LinkedBlockingDeque is capacity restricted and no space is left for insertion, it returns an IllegalStateException. It works exactly in the same way as addLast() m
    2 min read
  • LinkedBlockingDeque in Java with Examples
    The LinkedBlockingDeque class in Java is a part of the Java Collection Framework. It was introduced in JDK 1.6 and it belongs to java.util.concurrent package. It is a Deque(Doubly Ended Queue) which blocks a thread if that thread tries to take elements out of it while the Deque is empty. It implemen
    14 min read
  • LinkedBlockingDeque iterator() method in Java
    The iterator() method of LinkedBlockingDeque returns an iterator over the elements in this deque in a proper sequence. The elements will be returned in order from first (head) to last (tail). The returned iterator is a "weakly consistent" iterator. Syntax: public Iterator iterator() Parameters: This
    2 min read
  • LinkedBlockingDeque peekLast() method in Java
    The peekLast() method of LinkedBlockingDeque returns the last element in the Deque container, but does not deletes it. It returns null if the container is empty. Syntax: public E peekLast() Parameters: This method does not accept any parameters. Returns: This method returns last element in the Deque
    2 min read
  • LinkedBlockingDeque offer() method in Java
    The offer(E e) method of LinkedBlockingDeque inserts the element passed in the parameter to the end of the Deque. If the container's capacity has exceeded, then it does not returns an exception as in case of add() and addFirst() function. Syntax: public boolean offer(E e) Parameters: This method acc
    2 min read
  • LinkedBlockingDeque element() method in Java
    The element() method of LinkedBlockingDeque returns the element at the front the container. It does not deletes the element in the container. This method returns the head of the queue represented by this deque. Syntax: public void element() Parameters: This method does not accept any parameter. Retu
    2 min read
  • LinkedBlockingDeque addFirst() method in Java
    The addFirst(E e) method of LinkedBlockingDeque inserts the element passed in the parameter to the front of the Deque if there is space. If the LinkedBlockingDeque is capacity restricted and no space is left for insertion, it returns an IllegalStateException. Syntax: public void addFirst(E e) Parame
    2 min read
  • LinkedBlockingDeque pop() method in Java
    The pop() method of LinkedBlockingDeque pops an element from the stack represented by this deque. In other words, it removes and returns the first element of this deque. It returns null if the container is empty. Syntax: public E pop() Parameters: This method does not accept any parameters. Returns:
    2 min read
  • LinkedBlockingDeque getFirst() method in Java
    The getFirst() method of LinkedBlockingDeque returns the front most element in the Deque container. If the LinkedBlockingDeque is empty, then on function call it returns a NoSuchElementException. Syntax: public E getLast() Parameters: This method does not accept any parameters. Returns: This method
    2 min read
  • LinkedBlockingDeque clear() method in Java
    The clear() method of LinkedBlockingDeque erases all the elements that are present in the LinkedBlockingDeque container. The container becomes empty after the function is called. Syntax: public void clear() Parameters: This method does not accepts any parameters Returns: This method does not returns
    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