Below Java program will use ArrayDeque to keep a collection object and then prints those elements out in descending order.
import java.util.*; public class Reading { public static void main(String[] args) { ArrayList<String> books = new ArrayList<String>(); books.add("Hello USA!"); books.add("Roof Top"); books.add("Follow Alphabet Order"); Deque<String> reading = new ArrayDeque<String>(books); for (Iterator<String> iter = reading.descendingIterator(); iter.hasNext(); ) { String book = iter.next(); System.out.println(book); } } }
The outcome is as follows:-
Follow Alphabet Order Roof Top Hello USA!