- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
The listIterator() method of Java AbstractSequentialList class
The listIterator() method of the AbstractSequentialList class returns a list iterator over the elements in this list.
The syntax is as follows
public abstract ListIterator<E> listIterator(int index)
Here, index is the index of the first element to be returned from the list iterator. The ListIterator here is the iterator for lists.
To work with the AbstractSequentialList class in Java, you need to import the following package
import java.util.AbstractSequentialList;
The following is an example to implement AbstractSequentialList listIterator() method in Java
Example
import java.util.LinkedList; import java.util.ListIterator; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] args) { AbstractSequentialList<Integer> absSequential = new LinkedList<>(); absSequential.add(5); absSequential.add(12); absSequential.add(40); absSequential.add(55); absSequential.add(60); absSequential.add(70); absSequential.add(90); System.out.println("Elements in the AbstractSequentialList = "+absSequential); ListIterator<Integer> i = absSequential.listIterator(); while (i.hasNext()) { System.out.print(i.next() + " "); } } }
Output
Elements in the AbstractSequentialList = [5, 12, 40, 55, 60, 70, 90] 5 12 40 55 60 70 90
Advertisements