Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to use ListIterator in java

// Java code to illustrate the use of ListIterator
import java.io.*;
import java.util.*;
  
class Test {
    public static void main(String[] args)
    {
        ArrayList<String> list = new ArrayList<String>();
  
        list.add("A");
        list.add("B");
        list.add("C");
        list.add("D");
        list.add("E");
  
        // ListIterator to traverse the list
        ListIterator iterator = list.listIterator();
  
        // Traversing the list in forward direction
        System.out.println("Displaying list elements in forward direction : ");
  
        while (iterator.hasNext())
            System.out.print(iterator.next() + " ");
  
        System.out.println();
  
        // Traversing the list in backward direction
        System.out.println("Displaying list elements in backward direction : ");
  
        while (iterator.hasPrevious())
            System.out.print(iterator.previous() + " ");
  
        System.out.println();
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: node in java 
Java :: convertir string a char java 
Java :: java character 
Java :: tableau de chaîne de caractère en java 
Java :: Java User Input (Scanner) 
Java :: jpa page sort 
Java :: how to create a function in java 
Java :: set jcombobox index java 
Java :: get executable path java 
Java :: java methods 
Java :: print a list java 
Java :: Java Hashmap Add Elements 
Java :: spring valid request body custom message 
Java :: create hashmap in java 
Java :: what is exception in java 
Java :: get intersection of two lists java 
Java :: java create arraylist with size 
Java :: queue and stack reader 
Java :: multiple inheritance using interface in java 
Java :: Design a class ‘Complex ‘with data members for real and imaginary part. Provide default and Parameterized constructors. Write a program to perform arithmetic operations of two complex numbers. 
Java :: Using multiple delimiters with String Tokenizer 
Java :: MyArrayList 
Java :: declaring variables views in java android 
Java :: add infinite values to variable java 
Java :: how to spilt the string with comma in jaav 
Java :: double to string in java without tovalue 
Java :: how to check when edittext clicked android 
Java :: reader from string java 
Java :: exception handling in java 
Java :: what is a cache-less reload 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =