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:
ConcurrentLinkedDeque push() method in Java with Examples
Next article icon

ConcurrentLinkedDeque iterator() method in Java with Example

Last Updated : 24 Dec, 2018
Comments
Improve
Suggest changes
Like Article
Like
Report
The Java.util.concurrent.ConcurrentLinkedDeque.iterator() method is used to return an iterator of the same elements as that of the ConcurrentLinkedDeque. The elements are returned in random order from what was present in the deque. Syntax:
  Iterator iterate_value = ConcurrentLinkedDeque.iterator();  
Parameters: The function does not take any parameter. Return Value: The method iterates over the elements of the deque and returns the values(iterators). Below program illustrates the use of Java.util.concurrent.ConcurrentLinkedDeque.iterator() method: Example 1: Java
// Java code to illustrate iterator()  import java.util.concurrent.*; import java.util.*;  public class ConcurrentLinkedDequeDemo {     public static void main(String args[])     {         // Creating an empty ConcurrentLinkedDeque         ConcurrentLinkedDeque<String> deque             = new ConcurrentLinkedDeque<String>();          // Use add() method to add elements         // into the ConcurrentLinkedDeque         deque.add("Welcome");         deque.add("To");         deque.add("Geeks");         deque.add("4");         deque.add("Geeks");          // Displaying the ConcurrentLinkedDeque         System.out.println("ConcurrentLinkedDeque: "                            + deque);          // Creating an iterator         Iterator value = deque.iterator();          // Displaying the values         // after iterating through the deque         System.out.println("The iterator values are: ");         while (value.hasNext()) {             System.out.println(value.next());         }     } } 
Output:
  ConcurrentLinkedDeque: [Welcome, To, Geeks, 4, Geeks]  The iterator values are:   Welcome  To  Geeks  4  Geeks  
Example 2: ConcurrentLinkedDeque with integer elements. Java
// Java code to illustrate iterator()  import java.util.concurrent.*; import java.util.*;  public class ConcurrentLinkedDequeDemo {     public static void main(String args[])     {         // Creating an empty ConcurrentLinkedDeque         ConcurrentLinkedDeque<Integer> deque             = new ConcurrentLinkedDeque<Integer>();          // Use add() method         // to add elements into the ConcurrentLinkedDeque         deque.add(10);         deque.add(20);         deque.add(30);         deque.add(40);         deque.add(50);          // Displaying the ConcurrentLinkedDeque         System.out.println("ConcurrentLinkedDeque: "                            + deque);          // Creating an iterator         Iterator value = deque.iterator();          // Displaying the values         // after iterating through the deque         System.out.println("The iterator values are: ");         while (value.hasNext()) {             System.out.println(value.next());         }     } } 
Output:
  ConcurrentLinkedDeque: [10, 20, 30, 40, 50]  The iterator values are:   10  20  30  40  50  

Next Article
ConcurrentLinkedDeque push() method in Java with Examples

M

MerlynShelley
Improve
Article Tags :
  • Java
  • Technical Scripter
  • Technical Scripter 2018
  • Java-Collections
  • Java - util package
  • Java-Functions
  • Java-ConcurrentLinkedDeque
Practice Tags :
  • Java
  • Java-Collections

Similar Reads

  • ConcurrentLinkedDeque pop() method in Java with Examples
    The Java.util.ConcurrentLinkedDeque.pop() method in Java is used to pop an element from the ConcurrentLinkedDeque. The element is popped from the top of the ConcurrentLinkedDeque and is removed from the same.Syntax: ConcurrentLinkedDeque.pop() Parameters: The method does not take any parameters.Retu
    2 min read
  • ConcurrentLinkedDeque poll() method in Java with Example
    The poll() method of ConcurrentLinkedDeque returns the front element in the Deque container and deletes it. It returns null if the container is empty. Syntax: public E poll() Parameters: This method does not accept any parameters. Returns: This method returns front element of the Deque container if
    2 min read
  • ConcurrentLinkedDeque peek() method in Java with Example
    The java.util.ConcurrentLinkedDeque.peek() method in Java is used to retrieve or fetch the element at the head of the Deque. The element retrieved does not get deleted or removed from the Deque instead the method just returns it. If no element is present in the deque then Null is returned. Syntax: A
    2 min read
  • ConcurrentLinkedDeque push() method in Java with Examples
    The push() method of ConcurrentLinkedDeque class is an in-built function in Java which pushes an element onto the stack represented by this deque (in other words, at the head of this deque) if it is possible to do so immediately without violating capacity restrictions, returning true upon success an
    2 min read
  • ConcurrentLinkedDeque equals() method in Java with Example
    The equals() method of java.util.ConcurrentLinkedDeque class is used to compare the specified object with this ConcurrentLinkedDeque for equality. Returns true if and only if the specified object is also a ConcurrentLinkedDeque, both ConcurrentLinkedDeques have the same size, and all corresponding p
    2 min read
  • ConcurrentLinkedDeque offer() method in Java with Examples
    The java.util.concurrent.ConcurrentLinkedDeque.offer() method is an inbuilt method in Java which inserts the specified element, passed as a parameter, to the deque. Syntax: public boolean offer(E elem) Parameters: The method accepts a parameter elem which species the element to be inserted to the de
    2 min read
  • ConcurrentLinkedQueue iterator() method in Java
    The iterator() method of ConcurrentLinkedQueue is used to returns an iterator of the same elements as this ConcurrentLinkedQueue in a proper sequence. The elements returned from this method contains elements in order from first(head) to last(tail). The returned iterator is weakly consistent. Syntax:
    2 min read
  • ConcurrentLinkedDeque addAll() method in Java with Examples
    The addAll(Collection col) of ConcurrentLinkedDeque which takes col as a parameter, where col is a Collection of elements (List, ArrayList, LinkedList etc). This entire Collection gets appended or added to the end of the Dequeue. This method just like add() method returns true if the Collection gets
    3 min read
  • ConcurrentLinkedDeque toArray() method in Java with Example
    toArray() The Java.util.concurrent.ConcurrentLinkedDeque.toArray() method returns an array containing all the elements in the deque in proper sequence i.e. from first to last. The returned array will be safe as a new array is created (hence new memory is allocated). Thus the caller is free to modify
    3 min read
  • ConcurrentLinkedDeque remove() method in Java with Examples
    The java.util.concurrent.ConcurrentLinkedDeque.remove() is an in-built function in Java which is used to remove an element from this deque.Syntax: public E remove() or public boolean remove(Object o) Parameters: The first overload of this method does not accepts any parameter. However the second ove
    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