Java LinkedList iterate using descending Iterator

Description

Java LinkedList iterate using descending Iterator

import java.util.Iterator;
import java.util.LinkedList;

public class Main {
  public static void main(String... args) {
    LinkedList<String> list = new LinkedList<String>();
    list.add("CSS");
    list.add("HTML");
    list.add("Java");
    list.add("Javascript");
    list.add("SQL");

    Iterator<String> it = list.descendingIterator();
    while(it.hasNext()) {
      System.out.println(it.next());
    }    /*from ww w  . java  2  s  .c o m*/
    
    
  }
}



PreviousNext

Related