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:
Java AbstractSequentialList | iterator() method
Next article icon

Java AbstractSequentialList | iterator() method

Last Updated : 26 Nov, 2018
Comments
Improve
Suggest changes
Like Article
Like
Report
AbstractSequentialList iterator() method in Java is used to get an Iterator or List Iterator over a list. It returns an iterator over the elements in this list (in proper sequence). This method overrides iterator() in class AbstractList<E> Syntax:
public Iterator<E> iterator()
Return Value: This method returns an iterator over the elements in this list (in proper sequence). Below is the code to illustrate iterator() method: Program 1: Java
// Java program to demonstrate // iterator() method  import java.util.*;  public class GfG {      public static void main(String[] args)     {         // Creating an instance of the AbstractSequentialList         AbstractSequentialList<Integer> absl = new LinkedList<>();          // adding elements to absl         absl.add(5);         absl.add(6);         absl.add(7);         absl.add(2, 8);         absl.add(2, 7);         absl.add(1, 9);         absl.add(4, 10);          // Getting Iterator         Iterator<Integer> Itr = absl.iterator();          // Traversing elements with help of iterator         while (Itr.hasNext()) {             System.out.print(Itr.next() + " ");         }     } } 
Output:
  5 9 6 7 10 8 7  
Program 2: Java
// Java program to demonstrate // iterator() method  import java.util.*;  public class GfG {      public static void main(String[] args)     {         // Creating an instance of the AbstractSequentialList         AbstractSequentialList<String> absl = new LinkedList<>();          // adding elements to absl         absl.add("Geeks");         absl.add("ForGeeks");         absl.add("A");         absl.add("Portal");         absl.add(3, "Computer Science");         absl.add(5, "For Geeks");          // Getting Iterator         Iterator<String> Itr = absl.iterator();          // Traversing elements with help of iterator         while (Itr.hasNext()) {             System.out.println(Itr.next());         }     } } 
Output:
  Geeks  ForGeeks  A  Computer Science  Portal  For Geeks  

Next Article
Java AbstractSequentialList | iterator() method

B

barykrg
Improve
Article Tags :
  • Misc
  • Java
  • Java-Collections
  • Java - util package
  • Java-Functions
  • java-AbstractSequentialList
Practice Tags :
  • Java
  • Java-Collections
  • Misc

Similar Reads

    AbstractSequentialList get() method in Java with Examples
    The get() method of AbstractSequentialList is used to fetch or retrieve an element at a specific index from a AbstractSequentialList. Syntax: AbstractSequentialList.get(int index) Parameters: The parameter index is of integer data type that specifies the position or index of the element to be fetche
    2 min read
    Java AbstractSequentialList | add()
    AbstractSequentialList uses the add() method specified by the List interface and overridden in class AbstractList. Hence AbstractSequentialList do not have a add() method of its own. Instead it has add(int index, E element) method. AbstractSequentialList add(int index, E element) method inserts the
    3 min read
    AbstractSequentialList set() method in Java with Examples
    The set() method of Java.util.AbstractSequentialList is used to replace any particular element in the sequential list created using the LinkedList class with another element. This can be done by specifying the position of the element to be replaced and the new element in the parameter of the set() m
    3 min read
    Java AbstractSequentialList | ListIterator()
    AbstractSequentialList listIterator(): method in Java is used to get a listIterator over this list. It returns a list iterator over the elements in this list (in proper sequence). Syntax: public abstract ListIterator listIterator(int index) Parameters: This method takes a parameter index which is th
    2 min read
    ArrayDeque iterator() Method in Java
    The Java.util.ArrayDeque.iterator() method is used to return an iterator of the elements of the ArrayDeque. Syntax: Iterator iterate_value = Array_Deque.iterator(); Parameters: The method does not take any parameter. Return Value: The method iterates over the elements of the deque and returns the va
    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